Merge branch 'feature/npm-refactor-poc'

This commit is contained in:
SPRINX0\prochazka
2024-11-14 15:40:17 +01:00
61 changed files with 455 additions and 359 deletions

View File

@@ -47,9 +47,6 @@ jobs:
yarn printSecrets yarn printSecrets
env: env:
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
- name: fillNativeModulesElectron
run: |
yarn fillNativeModulesElectron
- name: fillPackagedPlugins - name: fillPackagedPlugins
run: | run: |
yarn fillPackagedPlugins yarn fillPackagedPlugins

View File

@@ -55,11 +55,11 @@ jobs:
cd .. cd ..
cd dbgate-merged cd dbgate-merged
yarn adjustPackageJson yarn adjustPackageJson
- name: adjustPackageJsonPremium - name: adjustAppPackageJsonPremium
run: | run: |
cd .. cd ..
cd dbgate-merged cd dbgate-merged
node adjustPackageJsonPremium node adjustAppPackageJsonPremium
- name: setUpdaterChannel premium-beta - name: setUpdaterChannel premium-beta
run: | run: |
cd .. cd ..
@@ -87,11 +87,6 @@ jobs:
yarn printSecrets yarn printSecrets
env: env:
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
- name: fillNativeModulesElectron
run: |
cd ..
cd dbgate-merged
yarn fillNativeModulesElectron
- name: fillPackagedPlugins - name: fillPackagedPlugins
run: | run: |
cd .. cd ..

View File

@@ -56,11 +56,11 @@ jobs:
cd .. cd ..
cd dbgate-merged cd dbgate-merged
yarn adjustPackageJson yarn adjustPackageJson
- name: yarn adjustPackageJsonPremium - name: adjustAppPackageJsonPremium
run: | run: |
cd .. cd ..
cd dbgate-merged cd dbgate-merged
node adjustPackageJsonPremium node adjustAppPackageJsonPremium
- name: setUpdaterChannel premium - name: setUpdaterChannel premium
run: | run: |
cd .. cd ..
@@ -88,11 +88,6 @@ jobs:
yarn printSecrets yarn printSecrets
env: env:
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
- name: fillNativeModulesElectron
run: |
cd ..
cd dbgate-merged
yarn fillNativeModulesElectron
- name: fillPackagedPlugins - name: fillPackagedPlugins
run: | run: |
cd .. cd ..

View File

@@ -50,9 +50,6 @@ jobs:
yarn printSecrets yarn printSecrets
env: env:
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
- name: fillNativeModulesElectron
run: |
yarn fillNativeModulesElectron
- name: fillPackagedPlugins - name: fillPackagedPlugins
run: | run: |
yarn fillPackagedPlugins yarn fillPackagedPlugins

View File

@@ -54,6 +54,12 @@ jobs:
node sync.js --nowatch node sync.js --nowatch
cd .. cd ..
- name: yarn adjustPackageJson
run: |
cd ..
cd dbgate-merged
yarn adjustPackageJson
- name: yarn install - name: yarn install
run: | run: |
cd .. cd ..

View File

@@ -62,6 +62,12 @@ jobs:
node sync.js --nowatch node sync.js --nowatch
cd .. cd ..
- name: yarn adjustPackageJson
run: |
cd ..
cd dbgate-merged
yarn adjustPackageJson
- name: yarn install - name: yarn install
run: | run: |
cd .. cd ..

View File

@@ -56,6 +56,13 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 18.x node-version: 18.x
- name: yarn adjustPackageJson
run: |
cd ..
cd dbgate-merged
yarn adjustPackageJson
- name: yarn install - name: yarn install
run: | run: |
# yarn --version # yarn --version

113
.github/workflows/build-npm-pro.yaml vendored Normal file
View File

@@ -0,0 +1,113 @@
name: NPM packages PREMIUM
# on: [push]
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
# on:
# push:
# branches:
# - production
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Checkout dbgate/dbgate-pro
uses: actions/checkout@v2
with:
repository: dbgate/dbgate-pro
token: ${{ secrets.GH_TOKEN }}
path: dbgate-pro
- name: Merge dbgate/dbgate-pro
run: |
mkdir ../dbgate-pro
mv dbgate-pro/* ../dbgate-pro/
cd ..
mkdir dbgate-merged
cd dbgate-pro
cd sync
yarn
node sync.js --nowatch
cd ..
- name: adjustNpmPackageJsonPremium
run: |
cd ..
cd dbgate-merged
node adjustNpmPackageJsonPremium
- name: Configure NPM token
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd ..
cd dbgate-merged
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- name: yarn install
run: |
cd ..
cd dbgate-merged
yarn install
- name: setCurrentVersion
run: |
cd ..
cd dbgate-merged
yarn setCurrentVersion
- name: printSecrets
run: |
cd ..
cd dbgate-merged
yarn printSecrets
env:
GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}}
- name: Publish dbgate-api-premium
run: |
cd ..
cd dbgate-merged/packages/api
npm publish
- name: Publish dbgate-web-premium
run: |
cd ..
cd dbgate-merged/packages/web
npm publish
- name: Publish dbgate-serve-premium
run: |
cd ..
cd dbgate-merged/packages/serve
npm publish
- name: Publish dbgate-plugin-cosmosdb
run: |
cd ..
cd dbgate-merged/plugins/dbgate-plugin-cosmosdb
npm publish

View File

@@ -90,11 +90,6 @@ jobs:
run: | run: |
npm publish npm publish
- name: Publish dbgate (obsolete)
working-directory: packages/dbgate
run: |
npm publish
- name: Publish dbgate-serve - name: Publish dbgate-serve
working-directory: packages/serve working-directory: packages/serve
run: | run: |

2
.gitignore vendored
View File

@@ -28,8 +28,6 @@ docker/plugins
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
app/src/nativeModulesContent.js
packages/api/src/nativeModulesContent.js
packages/api/src/packagedPluginsContent.js packages/api/src/packagedPluginsContent.js
.VSCodeCounter .VSCodeCounter

View File

@@ -1,10 +1,34 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path');
function adjustFile(file) { function adjustFile(file) {
const json = JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' })); const json = JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));
for (const packageName of fs.readdirSync('plugins')) {
if (!packageName.startsWith('dbgate-plugin-')) continue;
const pluginJson = JSON.parse(
fs.readFileSync(path.join('plugins', packageName, 'package.json'), { encoding: 'utf-8' })
);
for (const depkey of ['dependencies', 'optionalDependencies']) {
for (const dependency of Object.keys(pluginJson[depkey] || {})) {
if (!json[depkey]) {
json[depkey] = {};
}
if (json[depkey][dependency]) {
if (json[depkey][dependency] != pluginJson[depkey][dependency]) {
console.log(`Dependency ${dependency} in ${packageName} is different from ${file}`);
}
continue;
}
json[depkey][dependency] = pluginJson[depkey][dependency];
}
}
}
if (process.platform != 'win32') { if (process.platform != 'win32') {
delete json.optionalDependencies.msnodesqlv8; delete json.optionalDependencies.msnodesqlv8;
} }
fs.writeFileSync(file, JSON.stringify(json, null, 2), 'utf-8'); fs.writeFileSync(file, JSON.stringify(json, null, 2), 'utf-8');
} }

View File

@@ -130,10 +130,5 @@
"electron": "30.0.2", "electron": "30.0.2",
"electron-builder": "23.1.0", "electron-builder": "23.1.0",
"electron-builder-notarize": "^1.5.2" "electron-builder-notarize": "^1.5.2"
},
"optionalDependencies": {
"better-sqlite3": "9.6.0",
"msnodesqlv8": "^4.2.1",
"oracledb": "^6.6.0"
} }
} }

View File

@@ -430,7 +430,6 @@ function createWindow() {
); );
global.API_PACKAGE = apiPackage; global.API_PACKAGE = apiPackage;
global.NATIVE_MODULES = path.join(__dirname, 'nativeModules');
// console.log('global.API_PACKAGE', global.API_PACKAGE); // console.log('global.API_PACKAGE', global.API_PACKAGE);
const api = require(apiPackage); const api = require(apiPackage);

View File

@@ -1,3 +0,0 @@
const content = require('./nativeModulesContent');
module.exports = content;

View File

@@ -1,24 +0,0 @@
const fs = require('fs');
let fillContent = '';
if (process.platform == 'win32') {
fillContent += `content.msnodesqlv8 = () => require('msnodesqlv8');\n`;
}
fillContent += `content['better-sqlite3'] = () => require('better-sqlite3');\n`;
fillContent += `content['oracledb'] = () => require('oracledb');\n`;
const getContent = empty => `
// this file is generated automatically by script fillNativeModules.js, do not edit it manually
const content = {};
${empty ? '' : fillContent}
module.exports = content;
`;
fs.writeFileSync(
'packages/api/src/nativeModulesContent.js',
getContent(process.argv.includes('--electron') ? true : false)
);
fs.writeFileSync('app/src/nativeModulesContent.js', getContent(false));

View File

@@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"version": "5.5.7-alpha.29", "version": "5.5.7-alpha.51",
"name": "dbgate-all", "name": "dbgate-all",
"workspaces": [ "workspaces": [
"packages/*", "packages/*",
@@ -47,8 +47,6 @@
"printSecrets": "node printSecrets", "printSecrets": "node printSecrets",
"generatePadFile": "node generatePadFile", "generatePadFile": "node generatePadFile",
"adjustPackageJson": "node adjustPackageJson", "adjustPackageJson": "node adjustPackageJson",
"fillNativeModules": "node fillNativeModules",
"fillNativeModulesElectron": "node fillNativeModules --electron",
"fillPackagedPlugins": "node fillPackagedPlugins", "fillPackagedPlugins": "node fillPackagedPlugins",
"resetPackagedPlugins": "node resetPackagedPlugins", "resetPackagedPlugins": "node resetPackagedPlugins",
"prettier": "prettier --write packages/api/src && prettier --write packages/datalib/src && prettier --write packages/filterparser/src && prettier --write packages/sqltree/src && prettier --write packages/tools/src && prettier --write packages/types && prettier --write packages/web/src && prettier --write app/src", "prettier": "prettier --write packages/api/src && prettier --write packages/datalib/src && prettier --write packages/filterparser/src && prettier --write packages/sqltree/src && prettier --write packages/tools/src && prettier --write packages/types && prettier --write packages/web/src && prettier --write app/src",
@@ -62,7 +60,7 @@
"ts:api": "yarn workspace dbgate-api ts", "ts:api": "yarn workspace dbgate-api ts",
"ts:web": "yarn workspace dbgate-web ts", "ts:web": "yarn workspace dbgate-web ts",
"ts": "yarn ts:api && yarn ts:web", "ts": "yarn ts:api && yarn ts:web",
"postinstall": "yarn resetPackagedPlugins && yarn build:lib && patch-package && yarn fillNativeModules && yarn build:plugins:frontend", "postinstall": "yarn resetPackagedPlugins && yarn build:lib && patch-package && yarn build:plugins:frontend",
"dbgate-serve": "node packages/dbgate/bin/dbgate-serve.js" "dbgate-serve": "node packages/dbgate/bin/dbgate-serve.js"
}, },
"dependencies": { "dependencies": {

View File

@@ -19,7 +19,7 @@
"dependencies": { "dependencies": {
"@aws-sdk/rds-signer": "^3.665.0", "@aws-sdk/rds-signer": "^3.665.0",
"activedirectory2": "^2.1.0", "activedirectory2": "^2.1.0",
"async-lock": "^1.2.4", "async-lock": "^1.2.6",
"axios": "^0.21.1", "axios": "^0.21.1",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"bufferutil": "^4.0.1", "bufferutil": "^4.0.1",
@@ -85,10 +85,5 @@
"typescript": "^4.4.3", "typescript": "^4.4.3",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"optionalDependencies": {
"better-sqlite3": "9.6.0",
"msnodesqlv8": "^4.2.1",
"oracledb": "^6.6.0"
} }
} }

View File

@@ -94,7 +94,7 @@ module.exports = {
if (!manifest.keywords) { if (!manifest.keywords) {
continue; continue;
} }
if (!manifest.keywords.includes('dbgateplugin')) { if (!manifest.keywords.includes('dbgateplugin') && !manifest.keywords.includes('dbgatebuiltin')) {
continue; continue;
} }
const readmeFile = path.join(isPackaged ? packagedPluginsDir() : pluginsdir(), packageName, 'README.md'); const readmeFile = path.join(isPackaged ? packagedPluginsDir() : pluginsdir(), packageName, 'README.md');

View File

@@ -36,6 +36,7 @@ const _ = require('lodash');
const { getLogger } = require('dbgate-tools'); const { getLogger } = require('dbgate-tools');
const { getDefaultAuthProvider } = require('./auth/authProvider'); const { getDefaultAuthProvider } = require('./auth/authProvider');
const startCloudUpgradeTimer = require('./utility/cloudUpgrade'); const startCloudUpgradeTimer = require('./utility/cloudUpgrade');
const { isProApp } = require('./utility/checkLicense');
const logger = getLogger('main'); const logger = getLogger('main');
@@ -77,7 +78,10 @@ function start() {
} else if (platformInfo.isAwsUbuntuLayout) { } else if (platformInfo.isAwsUbuntuLayout) {
app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public')); app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public'));
} else if (platformInfo.isNpmDist) { } else if (platformInfo.isNpmDist) {
app.use(getExpressPath('/'), express.static(path.join(__dirname, '../../dbgate-web/public'))); app.use(
getExpressPath('/'),
express.static(path.join(__dirname, isProApp() ? '../../dbgate-web-premium/public' : '../../dbgate-web/public'))
);
} else if (process.env.DEVWEB) { } else if (process.env.DEVWEB) {
// console.log('__dirname', __dirname); // console.log('__dirname', __dirname);
// console.log(path.join(__dirname, '../../web/public/build')); // console.log(path.join(__dirname, '../../web/public/build'));

View File

@@ -1,13 +0,0 @@
const argIndex = process.argv.indexOf('--native-modules');
const redirectFile = global['NATIVE_MODULES'] || (argIndex > 0 ? process.argv[argIndex + 1] : null);
function requireDynamic(file) {
try {
// @ts-ignore
return __non_webpack_require__(redirectFile);
} catch (err) {
return require(redirectFile);
}
}
module.exports = redirectFile ? requireDynamic(redirectFile) : require('./nativeModulesContent');

View File

@@ -1,7 +1,6 @@
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../utility/directories'); const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../utility/directories');
const nativeModules = require('../nativeModules');
const platformInfo = require('../utility/platformInfo'); const platformInfo = require('../utility/platformInfo');
const authProxy = require('../utility/authProxy'); const authProxy = require('../utility/authProxy');
const { getLogger } = require('dbgate-tools'); const { getLogger } = require('dbgate-tools');
@@ -11,7 +10,6 @@ const loadedPlugins = {};
const dbgateEnv = { const dbgateEnv = {
dbgateApi: null, dbgateApi: null,
nativeModules,
platformInfo, platformInfo,
authProxy, authProxy,
}; };

View File

@@ -12,7 +12,12 @@ function checkLicenseKey(key) {
}; };
} }
function isProApp() {
return false;
}
module.exports = { module.exports = {
checkLicense, checkLicense,
checkLicenseKey, checkLicenseKey,
isProApp,
}; };

View File

@@ -17,9 +17,6 @@ const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
function getPassArgs() { function getPassArgs() {
const res = []; const res = [];
if (global['NATIVE_MODULES']) {
res.push('--native-modules', global['NATIVE_MODULES']);
}
if (global['PLUGINS_DIR']) { if (global['PLUGINS_DIR']) {
res.push('--plugins-dir', global['PLUGINS_DIR']); res.push('--plugins-dir', global['PLUGINS_DIR']);
} }

View File

@@ -1,2 +0,0 @@
# DbGate - database administration tool
This package is obsolete, please use [dbgate-serve](https://www.npmjs.com/package/dbgate-serve) package instead

View File

@@ -1,17 +0,0 @@
{
"name": "dbgate",
"version": "5.0.0-alpha.1",
"homepage": "https://dbgate.org/",
"repository": {
"type": "git",
"url": "https://github.com/dbgate/dbgate.git"
},
"description": "Opensource database administration tool - web interface",
"author": "Jan Prochazka",
"license": "GPL-3.0",
"keywords": [
"sql",
"dbgate",
"web"
]
}

View File

@@ -2,9 +2,55 @@
[![NPM version](https://img.shields.io/npm/v/dbgate.svg)](https://www.npmjs.com/package/dbgate) [![NPM version](https://img.shields.io/npm/v/dbgate.svg)](https://www.npmjs.com/package/dbgate)
# DbGate - database administration tool # DbGate - database administration tool
DbGate is fast and easy to use database administration tool for MySQL, PostgreSQL, SQL Server. DbGate is cross-platform database manager.
It's designed to be simple to use and effective, when working with more databases simultaneously.
But there are also many advanced features like schema compare, visual query designer, chart visualisation or batch export and import.
## Install using npm ## Supported databases
* MySQL
* PostgreSQL
* SQL Server
* Oracle
* MongoDB
* Redis
* SQLite
* Amazon Redshift (Premium)
* CockroachDB
* MariaDB
* CosmosDB (Premium)
* ClickHouse
## Community vs Premium
This package has 2 variants:
* [dbgate-serve](https://www.npmjs.com/package/dbgate-serve) - Community edition (free and open source)
* [dbgate-serve-premium](https://www.npmjs.com/package/dbgate-serve-premium) - Premium edition (commercial)
## Install using npm - premium edition
```sh
npm install -g dbgate-serve-premium
```
DbGate is configure via environment variables. In this package, you could use .env files with configuration of DbGate. .env file is loaded in working directory.
.env file could look like following:
```
STORAGE_SERVER=localhost
STORAGE_USER=root
STORAGE_PASSWORD=mypassword
STORAGE_DATABASE=dbname
STORAGE_ENGINE=mysql@dbgate-plugin-mysql
```
You could find more about environment variable configuration on [DbGate docs](https://dbgate.org/docs/env-variables.html) page.
After installing, you can run dbgate with command:
```sh
dbgate-serve-premium
```
Then open http://localhost:3000 in your browser
## Install using npm - community edition
```sh ```sh
npm install -g dbgate-serve npm install -g dbgate-serve
``` ```
@@ -14,10 +60,21 @@ After installing, you can run dbgate with command:
dbgate-serve dbgate-serve
``` ```
.env file could be used in the same way as in Premium edition, without STORAGE_xxx variables, which are specific for Premium.
Then open http://localhost:3000 in your browser Then open http://localhost:3000 in your browser
## Download electron app ## Download desktop app
You can also download binary packages from https://dbgate.org . Or run from source code, as described on [github](https://github.com/dbgate/dbgate) You can also download binary packages for desktop app from https://dbgate.org . Or run from source code, as described on [github](https://github.com/dbgate/dbgate)
## Use Oracle with Instant client (thick mode)
If you are Oracle database user and you would like to use Oracle instant client (thick mode) instead of thin mode (pure JS NPM package), please make the following:
* Download Oracle instant client - https://www.oracle.com/cz/database/technologies/instant-client/downloads.html
* Unpack it somewhere (og. /opt/oracle in Linux systems)
* Configure ORACLE_INSTANT_CLIENT variable - should contain directory name of unpacked Instant client
If you don't know, whether you will need Instance client, please use this [table](https://node-oracledb.readthedocs.io/en/latest/user_guide/appendix_a.html) of features,
which are supported only in thick mode (with instant client). Eg. thin mode works from Oracle 12, if you have older Oracle server, you will need to install Oracle Instant client.
## Other dbgate packages ## Other dbgate packages
You can use some functionality of dbgate from your JavaScript code. See [dbgate-api](https://npmjs.com/dbgate-api) package. You can use some functionality of dbgate from your JavaScript code. See [dbgate-api](https://npmjs.com/dbgate-api) package.

View File

@@ -19,12 +19,16 @@
], ],
"dependencies": { "dependencies": {
"dbgate-api": "^5.0.0-alpha.1", "dbgate-api": "^5.0.0-alpha.1",
"dbgate-plugin-clickhouse": "^5.0.0-alpha.1",
"dbgate-plugin-csv": "^5.0.0-alpha.1", "dbgate-plugin-csv": "^5.0.0-alpha.1",
"dbgate-plugin-excel": "^5.0.0-alpha.1", "dbgate-plugin-excel": "^5.0.0-alpha.1",
"dbgate-plugin-mongo": "^5.0.0-alpha.1", "dbgate-plugin-mongo": "^5.0.0-alpha.1",
"dbgate-plugin-mssql": "^5.0.0-alpha.1", "dbgate-plugin-mssql": "^5.0.0-alpha.1",
"dbgate-plugin-mysql": "^5.0.0-alpha.1", "dbgate-plugin-mysql": "^5.0.0-alpha.1",
"dbgate-plugin-oracle": "^5.0.0-alpha.1",
"dbgate-plugin-postgres": "^5.0.0-alpha.1", "dbgate-plugin-postgres": "^5.0.0-alpha.1",
"dbgate-plugin-redis": "^5.0.0-alpha.1",
"dbgate-plugin-sqlite": "^5.0.0-alpha.1",
"dbgate-plugin-xml": "^5.0.0-alpha.1", "dbgate-plugin-xml": "^5.0.0-alpha.1",
"dbgate-web": "^5.0.0-alpha.1", "dbgate-web": "^5.0.0-alpha.1",
"dotenv": "^16.0.0" "dotenv": "^16.0.0"

View File

@@ -1,105 +1,3 @@
*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)* # dbgate-web
--- This package is used internally by [DbGate](https://dbgate.org)
# svelte app
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
```bash
npx degit sveltejs/template svelte-app
cd svelte-app
```
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
## Get started
Install the dependencies...
```bash
cd svelte-app
npm install
```
...then start [Rollup](https://rollupjs.org):
```bash
npm run dev
```
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
## Building and running in production mode
To create an optimised version of the app:
```bash
npm run build
```
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
## Single-page app mode
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
```js
"start": "sirv public --single"
```
## Using TypeScript
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
```bash
node scripts/setupTypeScript.js
```
Or remove the script via:
```bash
rm scripts/setupTypeScript.js
```
## Deploying to the web
### With [Vercel](https://vercel.com)
Install `vercel` if you haven't already:
```bash
npm install -g vercel
```
Then, from within your project folder:
```bash
cd public
vercel deploy --name my-project
```
### With [surge](https://surge.sh/)
Install `surge` if you haven't already:
```bash
npm install -g surge
```
Then, from within your project folder:
```bash
npm run build
surge public my-project.surge.sh
```

View File

@@ -7,8 +7,8 @@
"description": "Clickhouse connector for DbGate", "description": "Clickhouse connector for DbGate",
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin", "clickhouse",
"clickhouse" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -25,14 +25,14 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"byline": "^5.0.0",
"dbgate-plugin-tools": "^1.0.8", "dbgate-plugin-tools": "^1.0.8",
"dbgate-tools": "^5.0.0-alpha.1",
"json-stable-stringify": "^1.0.1",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
}, },
"dependencies": { "dependencies": {
"@clickhouse/client": "^1.5.0" "@clickhouse/client": "^1.5.0",
"dbgate-tools": "^5.0.0-alpha.1",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.21"
} }
} }

View File

@@ -18,6 +18,13 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
'@clickhouse/client': 'commonjs @clickhouse/client',
'json-stable-stringify': 'commonjs json-stable-stringify',
'dbgate-tools': 'commonjs dbgate-tools',
lodash: 'commonjs lodash',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -15,7 +15,7 @@
"import", "import",
"export", "export",
"dbgate", "dbgate",
"dbgateplugin" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -32,11 +32,13 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"csv": "^6.3.10",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"line-reader": "^0.4.0",
"lodash": "^4.17.21",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependencies": {
"csv": "^6.3.10",
"line-reader": "^0.4.0",
"lodash": "^4.17.21"
} }
} }

View File

@@ -1,4 +1,4 @@
const zipObject = require('lodash/zipObject'); const _ = require('lodash');
const csv = require('csv'); const csv = require('csv');
const fs = require('fs'); const fs = require('fs');
const stream = require('stream'); const stream = require('stream');
@@ -37,7 +37,7 @@ class CsvPrepareStream extends stream.Transform {
_transform(chunk, encoding, done) { _transform(chunk, encoding, done) {
if (this.structure) { if (this.structure) {
this.push( this.push(
zipObject( _.zipObject(
this.structure.columns.map((x) => x.columnName), this.structure.columns.map((x) => x.columnName),
chunk chunk
) )
@@ -57,7 +57,7 @@ class CsvPrepareStream extends stream.Transform {
}; };
this.push(this.structure); this.push(this.structure);
this.push( this.push(
zipObject( _.zipObject(
this.structure.columns.map((x) => x.columnName), this.structure.columns.map((x) => x.columnName),
chunk chunk
) )

View File

@@ -18,6 +18,12 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
csv: 'commonjs csv',
'line-reader': 'commonjs line-reader',
lodash: 'commonjs lodash',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -15,7 +15,7 @@
"import", "import",
"export", "export",
"dbgate", "dbgate",
"dbgateplugin" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -32,10 +32,12 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"lodash": "^4.17.21",
"xlsx": "0.16.9",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependecies": {
"lodash": "^4.17.21",
"xlsx": "0.16.9"
} }
} }

View File

@@ -18,6 +18,11 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
xlsx: 'commonjs xlsx',
lodash: 'commonjs lodash',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -12,9 +12,9 @@
}, },
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin",
"mongo", "mongo",
"mongodb" "mongodb",
"dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -31,15 +31,19 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"bson": "^6.8.0",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"bson": "^6.8.0",
"dbgate-query-splitter": "^4.11.2", "dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",
"is-promise": "^4.0.0", "is-promise": "^4.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mongodb": "^6.3.0", "mongodb": "^6.3.0"
"mongodb-client-encryption": "^6.0.0", },
"webpack": "^5.91.0", "optionalDependencies": {
"webpack-cli": "^5.1.4" "mongodb-client-encryption": "^6.0.0"
} }
} }

View File

@@ -18,6 +18,16 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
'dbgate-tools': 'commonjs dbgate-tools',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
lodash: 'commonjs lodash',
mongodb: 'commonjs mongodb',
'mongodb-client-encryption': 'commonjs mongodb-client-encryption',
bson: 'commonjs bson',
'is-promise': 'commonjs is-promise',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -14,7 +14,7 @@
"sql", "sql",
"mssql", "mssql",
"dbgate", "dbgate",
"dbgateplugin" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -31,12 +31,18 @@
"plugout": "dbgate-plugout dbgate-plugin-mssql" "plugout": "dbgate-plugout dbgate-plugin-mssql"
}, },
"devDependencies": { "devDependencies": {
"async-lock": "^1.2.6",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"tedious": "^18.2.0",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependencies": {
"async-lock": "^1.2.6",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"tedious": "^18.2.0"
},
"optionalDependencies": {
"msnodesqlv8": "^4.2.1"
} }
} }

View File

@@ -1,4 +1,3 @@
const fp = require('lodash/fp');
const _ = require('lodash'); const _ = require('lodash');
const sql = require('./sql'); const sql = require('./sql');

View File

@@ -5,15 +5,13 @@ const MsSqlAnalyser = require('./MsSqlAnalyser');
const createTediousBulkInsertStream = require('./createTediousBulkInsertStream'); const createTediousBulkInsertStream = require('./createTediousBulkInsertStream');
const createNativeBulkInsertStream = require('./createNativeBulkInsertStream'); const createNativeBulkInsertStream = require('./createNativeBulkInsertStream');
const AsyncLock = require('async-lock'); const AsyncLock = require('async-lock');
const nativeDriver = require('./nativeDriver');
const lock = new AsyncLock(); const lock = new AsyncLock();
const { tediousConnect, tediousQueryCore, tediousReadQuery, tediousStream } = require('./tediousDriver'); const { tediousConnect, tediousQueryCore, tediousReadQuery, tediousStream } = require('./tediousDriver');
const { nativeConnect, nativeQueryCore, nativeReadQuery, nativeStream } = nativeDriver; const { nativeConnect, nativeQueryCore, nativeReadQuery, nativeStream } = require('./nativeDriver');
const { getLogger } = global.DBGATE_PACKAGES['dbgate-tools']; const { getLogger } = global.DBGATE_PACKAGES['dbgate-tools'];
const logger = getLogger('mssqlDriver'); const logger = getLogger('mssqlDriver');
let requireMsnodesqlv8;
let platformInfo; let platformInfo;
let authProxy; let authProxy;
@@ -59,7 +57,7 @@ const driver = {
getAuthTypes() { getAuthTypes() {
const res = []; const res = [];
if (requireMsnodesqlv8) res.push(...windowsAuthTypes); if (platformInfo?.isWindows) res.push(...windowsAuthTypes);
if (authProxy.isAuthProxySupported()) { if (authProxy.isAuthProxySupported()) {
res.push( res.push(
@@ -82,7 +80,7 @@ const driver = {
async connect(conn) { async connect(conn) {
const { authType } = conn; const { authType } = conn;
const connectionType = requireMsnodesqlv8 && (authType == 'sspi' || authType == 'sql') ? 'msnodesqlv8' : 'tedious'; const connectionType = platformInfo?.isWindows && (authType == 'sspi' || authType == 'sql') ? 'msnodesqlv8' : 'tedious';
const client = connectionType == 'msnodesqlv8' ? await nativeConnect(conn) : await tediousConnect(conn); const client = connectionType == 'msnodesqlv8' ? await nativeConnect(conn) : await tediousConnect(conn);
return { return {
@@ -172,12 +170,8 @@ const driver = {
}; };
driver.initialize = dbgateEnv => { driver.initialize = dbgateEnv => {
if (dbgateEnv.nativeModules && dbgateEnv.nativeModules.msnodesqlv8) {
requireMsnodesqlv8 = dbgateEnv.nativeModules.msnodesqlv8;
}
platformInfo = dbgateEnv.platformInfo; platformInfo = dbgateEnv.platformInfo;
authProxy = dbgateEnv.authProxy; authProxy = dbgateEnv.authProxy;
nativeDriver.initialize(dbgateEnv);
}; };
module.exports = driver; module.exports = driver;

View File

@@ -1,7 +1,6 @@
const _ = require('lodash'); const _ = require('lodash');
const stream = require('stream'); const stream = require('stream');
const makeUniqueColumnNames = require('./makeUniqueColumnNames'); const makeUniqueColumnNames = require('./makeUniqueColumnNames');
let requireMsnodesqlv8;
const { extractDbNameFromComposite } = global.DBGATE_PACKAGES['dbgate-tools']; const { extractDbNameFromComposite } = global.DBGATE_PACKAGES['dbgate-tools'];
// async function nativeQueryCore(pool, sql, options) { // async function nativeQueryCore(pool, sql, options) {
@@ -24,7 +23,7 @@ const { extractDbNameFromComposite } = global.DBGATE_PACKAGES['dbgate-tools'];
let msnodesqlv8Value; let msnodesqlv8Value;
function getMsnodesqlv8() { function getMsnodesqlv8() {
if (!msnodesqlv8Value) { if (!msnodesqlv8Value) {
msnodesqlv8Value = requireMsnodesqlv8(); msnodesqlv8Value = require('msnodesqlv8');
} }
return msnodesqlv8Value; return msnodesqlv8Value;
} }
@@ -225,16 +224,9 @@ async function nativeStream(dbhan, sql, options) {
}); });
} }
const initialize = dbgateEnv => {
if (dbgateEnv.nativeModules && dbgateEnv.nativeModules.msnodesqlv8) {
requireMsnodesqlv8 = dbgateEnv.nativeModules.msnodesqlv8;
}
};
module.exports = { module.exports = {
nativeConnect, nativeConnect,
nativeQueryCore, nativeQueryCore,
nativeReadQuery, nativeReadQuery,
nativeStream, nativeStream,
initialize,
}; };

View File

@@ -17,6 +17,15 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
msnodesqlv8: 'commonjs msnodesqlv8',
'async-lock': 'commonjs async-lock',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
'dbgate-tools': 'commonjs dbgate-tools',
lodash: 'commonjs lodash',
tedious: 'commonjs tedious',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -13,8 +13,8 @@
"keywords": [ "keywords": [
"sql", "sql",
"dbgate", "dbgate",
"dbgateplugin", "mysql",
"mysql" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -31,12 +31,15 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"antares-mysql-dumper": "^0.0.1",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"mysql2": "^3.11.3",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependencies": {
"antares-mysql-dumper": "^0.0.1",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"mysql2": "^3.11.3"
} }
} }

View File

@@ -1,4 +1,3 @@
const fp = require('lodash/fp');
const _ = require('lodash'); const _ = require('lodash');
const sql = require('./sql'); const sql = require('./sql');
@@ -172,7 +171,7 @@ class Analyser extends DatabaseAnalyser {
})), })),
procedures: programmables.rows procedures: programmables.rows
.filter(x => x.objectType == 'PROCEDURE') .filter(x => x.objectType == 'PROCEDURE')
.map(fp.omit(['objectType'])) .map(x => _.omit(x, ['objectType']))
.map(x => ({ .map(x => ({
...x, ...x,
createSql: `DELIMITER //\n\nCREATE PROCEDURE \`${x.pureName}\`()\n${x.routineDefinition}\n\nDELIMITER ;\n`, createSql: `DELIMITER //\n\nCREATE PROCEDURE \`${x.pureName}\`()\n${x.routineDefinition}\n\nDELIMITER ;\n`,
@@ -181,7 +180,7 @@ class Analyser extends DatabaseAnalyser {
})), })),
functions: programmables.rows functions: programmables.rows
.filter(x => x.objectType == 'FUNCTION') .filter(x => x.objectType == 'FUNCTION')
.map(fp.omit(['objectType'])) .map(x => _.omit(x, ['objectType']))
.map(x => ({ .map(x => ({
...x, ...x,
createSql: `CREATE FUNCTION \`${x.pureName}\`()\nRETURNS ${x.returnDataType} ${ createSql: `CREATE FUNCTION \`${x.pureName}\`()\nRETURNS ${x.returnDataType} ${

View File

@@ -14,6 +14,14 @@ var config = {
libraryTarget: 'commonjs2', libraryTarget: 'commonjs2',
}, },
externals: {
'dbgate-tools': 'commonjs dbgate-tools',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
'antares-mysql-dumper': 'commonjs antares-mysql-dumper',
lodash: 'commonjs lodash',
mysql2: 'commonjs mysql2',
},
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -12,8 +12,8 @@
"author": "Rinie Kervel", "author": "Rinie Kervel",
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin", "oracle",
"oracle" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -31,10 +31,15 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.8", "dbgate-plugin-tools": "^1.0.8",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependencies": {
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21"
},
"optionalDependencies": {
"oracledb": "^6.6.0"
} }
} }

View File

@@ -1,4 +1,3 @@
const fp = require('lodash/fp');
const _ = require('lodash'); const _ = require('lodash');
const sql = require('./sql'); const sql = require('./sql');

View File

@@ -6,13 +6,12 @@ const Analyser = require('./Analyser');
const { createBulkInsertStreamBase, makeUniqueColumnNames } = global.DBGATE_PACKAGES['dbgate-tools']; const { createBulkInsertStreamBase, makeUniqueColumnNames } = global.DBGATE_PACKAGES['dbgate-tools'];
const createOracleBulkInsertStream = require('./createOracleBulkInsertStream'); const createOracleBulkInsertStream = require('./createOracleBulkInsertStream');
let requireOracledb;
let platformInfo; let platformInfo;
let oracledbValue; let oracledbValue;
function getOracledb() { function getOracledb() {
if (!oracledbValue) { if (!oracledbValue) {
oracledbValue = requireOracledb(); oracledbValue = require('oracledb');
} }
return oracledbValue; return oracledbValue;
} }
@@ -359,9 +358,6 @@ const driver = {
}; };
driver.initialize = dbgateEnv => { driver.initialize = dbgateEnv => {
if (dbgateEnv.nativeModules && dbgateEnv.nativeModules['oracledb']) {
requireOracledb = dbgateEnv.nativeModules['oracledb'];
}
platformInfo = dbgateEnv.platformInfo; platformInfo = dbgateEnv.platformInfo;
}; };

View File

@@ -35,6 +35,13 @@ var config = {
}, },
}), }),
], ],
externals: {
'dbgate-tools': 'commonjs dbgate-tools',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
lodash: 'commonjs lodash',
oracledb: 'commonjs oracledb',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -12,8 +12,8 @@
"author": "Jan Prochazka", "author": "Jan Prochazka",
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin", "postgresql",
"postgresql" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
@@ -31,14 +31,14 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"pg": "^8.11.5",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
}, },
"dependencies": { "dependencies": {
"pg-copy-streams": "^6.0.6" "pg-copy-streams": "^6.0.6",
"dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21",
"pg": "^8.11.5"
} }
} }

View File

@@ -1,4 +1,3 @@
const fp = require('lodash/fp');
const _ = require('lodash'); const _ = require('lodash');
const sql = require('./sql'); const sql = require('./sql');

View File

@@ -35,6 +35,14 @@ var config = {
}, },
}), }),
], ],
externals: {
'dbgate-tools': 'commonjs dbgate-tools',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
lodash: 'commonjs lodash',
pg: 'commonjs pg',
'pg-copy-streams': 'commonjs pg-copy-streams',
}
}; };
module.exports = config; module.exports = config;

View File

@@ -12,8 +12,8 @@
"author": "Jan Prochazka", "author": "Jan Prochazka",
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin", "redis",
"redis" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist" "dist"
@@ -30,11 +30,13 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"dbgate-query-splitter": "^4.11.2", "dbgate-query-splitter": "^4.11.2",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"async": "^3.2.3", "async": "^3.2.3",
"ioredis": "^5.4.1", "ioredis": "^5.4.1",
"node-redis-dump2": "^0.5.0" "node-redis-dump2": "^0.5.0"

View File

@@ -18,6 +18,14 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
'dbgate-tools': 'commmonjs dbgate-tools',
'dbgate-query-splitter': 'commmonjs dbgate-query-splitter',
lodash: 'commmonjs lodash',
async: 'commmonjs async',
ioredis: 'commmonjs ioredis',
'node-redis-dump2': 'commmonjs node-redis-dump2',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -1,41 +1,45 @@
{ {
"name": "dbgate-plugin-sqlite", "name": "dbgate-plugin-sqlite",
"main": "dist/backend.js", "main": "dist/backend.js",
"version": "5.0.0-alpha.1", "version": "5.0.0-alpha.1",
"homepage": "https://dbgate.org", "homepage": "https://dbgate.org",
"description": "SQLite connect plugin for DbGate", "description": "SQLite connect plugin for DbGate",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/dbgate/dbgate" "url": "https://github.com/dbgate/dbgate"
}, },
"author": "Jan Prochazka", "author": "Jan Prochazka",
"license": "GPL-3.0", "license": "GPL-3.0",
"keywords": [ "keywords": [
"dbgate", "dbgate",
"dbgateplugin", "sqlite",
"sqlite" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist", "dist",
"icon.svg" "icon.svg"
], ],
"scripts": { "scripts": {
"build:frontend": "webpack --config webpack-frontend.config", "build:frontend": "webpack --config webpack-frontend.config",
"build:frontend:watch": "webpack --watch --config webpack-frontend.config", "build:frontend:watch": "webpack --watch --config webpack-frontend.config",
"build:backend": "webpack --config webpack-backend.config.js", "build:backend": "webpack --config webpack-backend.config.js",
"build": "yarn build:frontend && yarn build:backend", "build": "yarn build:frontend && yarn build:backend",
"plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-sqlite", "plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-sqlite",
"copydist": "yarn build && yarn pack && dbgate-copydist ../dist/dbgate-plugin-sqlite", "copydist": "yarn build && yarn pack && dbgate-copydist ../dist/dbgate-plugin-sqlite",
"plugout": "dbgate-plugout dbgate-plugin-sqlite", "plugout": "dbgate-plugout dbgate-plugin-sqlite",
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-plugin-tools": "^1.0.4",
"dbgate-plugin-tools": "^1.0.4", "webpack": "^5.91.0",
"dbgate-query-splitter": "^4.11.2", "webpack-cli": "^5.1.4"
"byline": "^5.0.0", },
"webpack": "^5.91.0", "dependencies": {
"webpack-cli": "^5.1.4" "dbgate-tools": "^5.0.0-alpha.1",
} "lodash": "^4.17.21",
"dbgate-query-splitter": "^4.11.2"
},
"optionalDependencies": {
"better-sqlite3": "9.6.0"
} }
}

View File

@@ -1,5 +1,5 @@
const _ = require('lodash'); const _ = require('lodash');
const { DatabaseAnalyser } = global.DBGATE_PACKAGES['dbgate-tools'];; const { DatabaseAnalyser } = global.DBGATE_PACKAGES['dbgate-tools'];
const indexcolsQuery = ` const indexcolsQuery = `
SELECT SELECT

View File

@@ -7,12 +7,10 @@ const { getLogger, createBulkInsertStreamBase, extractErrorLogData } = global.DB
const logger = getLogger('sqliteDriver'); const logger = getLogger('sqliteDriver');
let requireBetterSqlite;
let betterSqliteValue; let betterSqliteValue;
function getBetterSqlite() { function getBetterSqlite() {
if (!betterSqliteValue) { if (!betterSqliteValue) {
betterSqliteValue = requireBetterSqlite(); betterSqliteValue = require('better-sqlite3');
} }
return betterSqliteValue; return betterSqliteValue;
} }
@@ -188,10 +186,6 @@ const driver = {
}, },
}; };
driver.initialize = (dbgateEnv) => { driver.initialize = (dbgateEnv) => {};
if (dbgateEnv.nativeModules && dbgateEnv.nativeModules['better-sqlite3']) {
requireBetterSqlite = dbgateEnv.nativeModules['better-sqlite3'];
}
};
module.exports = driver; module.exports = driver;

View File

@@ -18,6 +18,12 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
'dbgate-tools': 'commonjs dbgate-tools',
'dbgate-query-splitter': 'commonjs dbgate-query-splitter',
'better-sqlite3': 'commonjs better-sqlite3',
lodash: 'commonjs lodash',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -15,7 +15,7 @@
"import", "import",
"export", "export",
"dbgate", "dbgate",
"dbgateplugin" "dbgatebuiltin"
], ],
"files": [ "files": [
"dist" "dist"
@@ -31,9 +31,11 @@
"prepublishOnly": "yarn build" "prepublishOnly": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"node-xml-stream-parser": "^1.0.12",
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"webpack": "^5.91.0", "webpack": "^5.91.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
},
"dependencies": {
"node-xml-stream-parser": "^1.0.12"
} }
} }

View File

@@ -18,6 +18,9 @@ var config = {
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },
externals: {
'node-xml-stream-parser': 'commonjs node-xml-stream-parser',
},
}; };
module.exports = config; module.exports = config;

View File

@@ -39,19 +39,12 @@ changePackageFile('packages/types', json.version);
changePackageFile('packages/tools', json.version); changePackageFile('packages/tools', json.version);
changePackageFile('packages/web', json.version); changePackageFile('packages/web', json.version);
changePackageFile('packages/datalib', json.version); changePackageFile('packages/datalib', json.version);
changePackageFile('packages/dbgate', json.version);
changePackageFile('packages/serve', json.version); changePackageFile('packages/serve', json.version);
changePackageFile('packages/filterparser', json.version); changePackageFile('packages/filterparser', json.version);
changePackageFile('packages/dbmodel', json.version); changePackageFile('packages/dbmodel', json.version);
changePackageFile('plugins/dbgate-plugin-csv', json.version); for (const package of fs.readdirSync('plugins')) {
changePackageFile('plugins/dbgate-plugin-xml', json.version); if (!package.startsWith('dbgate-plugin-')) continue;
changePackageFile('plugins/dbgate-plugin-excel', json.version);
changePackageFile('plugins/dbgate-plugin-mssql', json.version); changePackageFile(`plugins/${package}`, json.version);
changePackageFile('plugins/dbgate-plugin-mysql', json.version); }
changePackageFile('plugins/dbgate-plugin-mongo', json.version);
changePackageFile('plugins/dbgate-plugin-postgres', json.version);
changePackageFile('plugins/dbgate-plugin-sqlite', json.version);
changePackageFile('plugins/dbgate-plugin-redis', json.version);
changePackageFile('plugins/dbgate-plugin-oracle', json.version);
changePackageFile('plugins/dbgate-plugin-clickhouse', json.version);