diff --git a/.github/workflows/build-app-beta.yaml b/.github/workflows/build-app-beta.yaml index 4a4697c19..24b326342 100644 --- a/.github/workflows/build-app-beta.yaml +++ b/.github/workflows/build-app-beta.yaml @@ -47,9 +47,6 @@ jobs: yarn printSecrets env: GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} - - name: fillNativeModulesElectron - run: | - yarn fillNativeModulesElectron - name: fillPackagedPlugins run: | yarn fillPackagedPlugins diff --git a/.github/workflows/build-app-pro-beta.yaml b/.github/workflows/build-app-pro-beta.yaml index 9b69277d9..df2a1712d 100644 --- a/.github/workflows/build-app-pro-beta.yaml +++ b/.github/workflows/build-app-pro-beta.yaml @@ -55,11 +55,11 @@ jobs: cd .. cd dbgate-merged yarn adjustPackageJson - - name: adjustPackageJsonPremium + - name: adjustAppPackageJsonPremium run: | cd .. cd dbgate-merged - node adjustPackageJsonPremium + node adjustAppPackageJsonPremium - name: setUpdaterChannel premium-beta run: | cd .. @@ -87,11 +87,6 @@ jobs: yarn printSecrets env: GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} - - name: fillNativeModulesElectron - run: | - cd .. - cd dbgate-merged - yarn fillNativeModulesElectron - name: fillPackagedPlugins run: | cd .. diff --git a/.github/workflows/build-app-pro.yaml b/.github/workflows/build-app-pro.yaml index 1170a7079..e505bb90b 100644 --- a/.github/workflows/build-app-pro.yaml +++ b/.github/workflows/build-app-pro.yaml @@ -56,11 +56,11 @@ jobs: cd .. cd dbgate-merged yarn adjustPackageJson - - name: yarn adjustPackageJsonPremium + - name: adjustAppPackageJsonPremium run: | cd .. cd dbgate-merged - node adjustPackageJsonPremium + node adjustAppPackageJsonPremium - name: setUpdaterChannel premium run: | cd .. @@ -88,11 +88,6 @@ jobs: yarn printSecrets env: GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} - - name: fillNativeModulesElectron - run: | - cd .. - cd dbgate-merged - yarn fillNativeModulesElectron - name: fillPackagedPlugins run: | cd .. diff --git a/.github/workflows/build-app.yaml b/.github/workflows/build-app.yaml index 492153279..4e3b56e0c 100644 --- a/.github/workflows/build-app.yaml +++ b/.github/workflows/build-app.yaml @@ -50,9 +50,6 @@ jobs: yarn printSecrets env: GIST_UPLOAD_SECRET : ${{secrets.GIST_UPLOAD_SECRET}} - - name: fillNativeModulesElectron - run: | - yarn fillNativeModulesElectron - name: fillPackagedPlugins run: | yarn fillPackagedPlugins diff --git a/.github/workflows/build-aws-pro-beta.yaml b/.github/workflows/build-aws-pro-beta.yaml index 2467552da..13fb7b0a0 100644 --- a/.github/workflows/build-aws-pro-beta.yaml +++ b/.github/workflows/build-aws-pro-beta.yaml @@ -54,6 +54,12 @@ jobs: node sync.js --nowatch cd .. + - name: yarn adjustPackageJson + run: | + cd .. + cd dbgate-merged + yarn adjustPackageJson + - name: yarn install run: | cd .. diff --git a/.github/workflows/build-docker-pro.yaml b/.github/workflows/build-docker-pro.yaml index f6f6eee61..af6476cfe 100644 --- a/.github/workflows/build-docker-pro.yaml +++ b/.github/workflows/build-docker-pro.yaml @@ -62,6 +62,12 @@ jobs: node sync.js --nowatch cd .. + - name: yarn adjustPackageJson + run: | + cd .. + cd dbgate-merged + yarn adjustPackageJson + - name: yarn install run: | cd .. diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index dd72ec537..9745324c8 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -56,6 +56,13 @@ jobs: uses: actions/setup-node@v1 with: node-version: 18.x + + - name: yarn adjustPackageJson + run: | + cd .. + cd dbgate-merged + yarn adjustPackageJson + - name: yarn install run: | # yarn --version diff --git a/.github/workflows/build-npm-pro.yaml b/.github/workflows/build-npm-pro.yaml new file mode 100644 index 000000000..3b7647501 --- /dev/null +++ b/.github/workflows/build-npm-pro.yaml @@ -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 diff --git a/.github/workflows/build-npm.yaml b/.github/workflows/build-npm.yaml index 83320018c..44e5e1d6e 100644 --- a/.github/workflows/build-npm.yaml +++ b/.github/workflows/build-npm.yaml @@ -90,11 +90,6 @@ jobs: run: | npm publish - - name: Publish dbgate (obsolete) - working-directory: packages/dbgate - run: | - npm publish - - name: Publish dbgate-serve working-directory: packages/serve run: | diff --git a/.gitignore b/.gitignore index 4fbefcafc..40255d24e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,8 +28,6 @@ docker/plugins npm-debug.log* yarn-debug.log* yarn-error.log* -app/src/nativeModulesContent.js -packages/api/src/nativeModulesContent.js packages/api/src/packagedPluginsContent.js .VSCodeCounter diff --git a/adjustPackageJson.js b/adjustPackageJson.js index d805f266e..7f064f7d6 100644 --- a/adjustPackageJson.js +++ b/adjustPackageJson.js @@ -1,10 +1,34 @@ const fs = require('fs'); +const path = require('path'); function adjustFile(file) { 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') { delete json.optionalDependencies.msnodesqlv8; } + fs.writeFileSync(file, JSON.stringify(json, null, 2), 'utf-8'); } diff --git a/app/package.json b/app/package.json index 6ad0ee288..86d3acd49 100644 --- a/app/package.json +++ b/app/package.json @@ -130,10 +130,5 @@ "electron": "30.0.2", "electron-builder": "23.1.0", "electron-builder-notarize": "^1.5.2" - }, - "optionalDependencies": { - "better-sqlite3": "9.6.0", - "msnodesqlv8": "^4.2.1", - "oracledb": "^6.6.0" } } diff --git a/app/src/electron.js b/app/src/electron.js index 715067197..8106380f3 100644 --- a/app/src/electron.js +++ b/app/src/electron.js @@ -430,7 +430,6 @@ function createWindow() { ); global.API_PACKAGE = apiPackage; - global.NATIVE_MODULES = path.join(__dirname, 'nativeModules'); // console.log('global.API_PACKAGE', global.API_PACKAGE); const api = require(apiPackage); diff --git a/app/src/nativeModules.js b/app/src/nativeModules.js deleted file mode 100644 index 03a2f2c06..000000000 --- a/app/src/nativeModules.js +++ /dev/null @@ -1,3 +0,0 @@ -const content = require('./nativeModulesContent'); - -module.exports = content; diff --git a/fillNativeModules.js b/fillNativeModules.js deleted file mode 100644 index 23024893d..000000000 --- a/fillNativeModules.js +++ /dev/null @@ -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)); diff --git a/package.json b/package.json index 9e7128b5c..fa0a9f576 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "5.5.7-alpha.29", + "version": "5.5.7-alpha.51", "name": "dbgate-all", "workspaces": [ "packages/*", @@ -47,8 +47,6 @@ "printSecrets": "node printSecrets", "generatePadFile": "node generatePadFile", "adjustPackageJson": "node adjustPackageJson", - "fillNativeModules": "node fillNativeModules", - "fillNativeModulesElectron": "node fillNativeModules --electron", "fillPackagedPlugins": "node fillPackagedPlugins", "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", @@ -62,7 +60,7 @@ "ts:api": "yarn workspace dbgate-api ts", "ts:web": "yarn workspace dbgate-web ts", "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" }, "dependencies": { diff --git a/packages/api/package.json b/packages/api/package.json index 41d6b6746..4b296d293 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -19,7 +19,7 @@ "dependencies": { "@aws-sdk/rds-signer": "^3.665.0", "activedirectory2": "^2.1.0", - "async-lock": "^1.2.4", + "async-lock": "^1.2.6", "axios": "^0.21.1", "body-parser": "^1.19.0", "bufferutil": "^4.0.1", @@ -85,10 +85,5 @@ "typescript": "^4.4.3", "webpack": "^5.91.0", "webpack-cli": "^5.1.4" - }, - "optionalDependencies": { - "better-sqlite3": "9.6.0", - "msnodesqlv8": "^4.2.1", - "oracledb": "^6.6.0" } } diff --git a/packages/api/src/controllers/plugins.js b/packages/api/src/controllers/plugins.js index 5af0c0458..2b74a4669 100644 --- a/packages/api/src/controllers/plugins.js +++ b/packages/api/src/controllers/plugins.js @@ -94,7 +94,7 @@ module.exports = { if (!manifest.keywords) { continue; } - if (!manifest.keywords.includes('dbgateplugin')) { + if (!manifest.keywords.includes('dbgateplugin') && !manifest.keywords.includes('dbgatebuiltin')) { continue; } const readmeFile = path.join(isPackaged ? packagedPluginsDir() : pluginsdir(), packageName, 'README.md'); diff --git a/packages/api/src/main.js b/packages/api/src/main.js index ad77278be..9fb3fbe53 100644 --- a/packages/api/src/main.js +++ b/packages/api/src/main.js @@ -36,6 +36,7 @@ const _ = require('lodash'); const { getLogger } = require('dbgate-tools'); const { getDefaultAuthProvider } = require('./auth/authProvider'); const startCloudUpgradeTimer = require('./utility/cloudUpgrade'); +const { isProApp } = require('./utility/checkLicense'); const logger = getLogger('main'); @@ -77,7 +78,10 @@ function start() { } else if (platformInfo.isAwsUbuntuLayout) { app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public')); } 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) { // console.log('__dirname', __dirname); // console.log(path.join(__dirname, '../../web/public/build')); diff --git a/packages/api/src/nativeModules.js b/packages/api/src/nativeModules.js deleted file mode 100644 index 954acbaa0..000000000 --- a/packages/api/src/nativeModules.js +++ /dev/null @@ -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'); diff --git a/packages/api/src/shell/requirePlugin.js b/packages/api/src/shell/requirePlugin.js index 4bb00c997..23393d40a 100644 --- a/packages/api/src/shell/requirePlugin.js +++ b/packages/api/src/shell/requirePlugin.js @@ -1,7 +1,6 @@ const path = require('path'); const fs = require('fs'); const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../utility/directories'); -const nativeModules = require('../nativeModules'); const platformInfo = require('../utility/platformInfo'); const authProxy = require('../utility/authProxy'); const { getLogger } = require('dbgate-tools'); @@ -11,7 +10,6 @@ const loadedPlugins = {}; const dbgateEnv = { dbgateApi: null, - nativeModules, platformInfo, authProxy, }; diff --git a/packages/api/src/utility/checkLicense.js b/packages/api/src/utility/checkLicense.js index a21a66c40..caefc934a 100644 --- a/packages/api/src/utility/checkLicense.js +++ b/packages/api/src/utility/checkLicense.js @@ -12,7 +12,12 @@ function checkLicenseKey(key) { }; } +function isProApp() { + return false; +} + module.exports = { checkLicense, checkLicenseKey, + isProApp, }; diff --git a/packages/api/src/utility/processArgs.js b/packages/api/src/utility/processArgs.js index 6bf866512..b00877cce 100644 --- a/packages/api/src/utility/processArgs.js +++ b/packages/api/src/utility/processArgs.js @@ -17,9 +17,6 @@ const listenApiChild = process.argv.includes('--listen-api-child') || listenApi; function getPassArgs() { const res = []; - if (global['NATIVE_MODULES']) { - res.push('--native-modules', global['NATIVE_MODULES']); - } if (global['PLUGINS_DIR']) { res.push('--plugins-dir', global['PLUGINS_DIR']); } diff --git a/packages/dbgate/README.md b/packages/dbgate/README.md deleted file mode 100644 index cbd76c9d5..000000000 --- a/packages/dbgate/README.md +++ /dev/null @@ -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 diff --git a/packages/dbgate/package.json b/packages/dbgate/package.json deleted file mode 100644 index 7572cffc3..000000000 --- a/packages/dbgate/package.json +++ /dev/null @@ -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" - ] -} diff --git a/packages/serve/README.md b/packages/serve/README.md index 3361a812f..b6f1a65ca 100644 --- a/packages/serve/README.md +++ b/packages/serve/README.md @@ -2,9 +2,55 @@ [![NPM version](https://img.shields.io/npm/v/dbgate.svg)](https://www.npmjs.com/package/dbgate) # 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 npm install -g dbgate-serve ``` @@ -14,10 +60,21 @@ After installing, you can run dbgate with command: 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 -## Download electron 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) +## Download desktop app +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 You can use some functionality of dbgate from your JavaScript code. See [dbgate-api](https://npmjs.com/dbgate-api) package. diff --git a/packages/serve/package.json b/packages/serve/package.json index 53582d19b..83832f483 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -19,12 +19,16 @@ ], "dependencies": { "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-excel": "^5.0.0-alpha.1", "dbgate-plugin-mongo": "^5.0.0-alpha.1", "dbgate-plugin-mssql": "^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-redis": "^5.0.0-alpha.1", + "dbgate-plugin-sqlite": "^5.0.0-alpha.1", "dbgate-plugin-xml": "^5.0.0-alpha.1", "dbgate-web": "^5.0.0-alpha.1", "dotenv": "^16.0.0" diff --git a/packages/web/README.md b/packages/web/README.md index 7b1ba8363..41f1d6bbe 100644 --- a/packages/web/README.md +++ b/packages/web/README.md @@ -1,105 +1,3 @@ -*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)* +# dbgate-web ---- - -# 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 -``` +This package is used internally by [DbGate](https://dbgate.org) diff --git a/plugins/dbgate-plugin-clickhouse/package.json b/plugins/dbgate-plugin-clickhouse/package.json index 8d7c5e477..d9d04f007 100644 --- a/plugins/dbgate-plugin-clickhouse/package.json +++ b/plugins/dbgate-plugin-clickhouse/package.json @@ -7,8 +7,8 @@ "description": "Clickhouse connector for DbGate", "keywords": [ "dbgate", - "dbgateplugin", - "clickhouse" + "clickhouse", + "dbgatebuiltin" ], "files": [ "dist", @@ -25,14 +25,14 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "byline": "^5.0.0", "dbgate-plugin-tools": "^1.0.8", - "dbgate-tools": "^5.0.0-alpha.1", - "json-stable-stringify": "^1.0.1", "webpack": "^5.91.0", "webpack-cli": "^5.1.4" }, "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" } } diff --git a/plugins/dbgate-plugin-clickhouse/webpack-backend.config.js b/plugins/dbgate-plugin-clickhouse/webpack-backend.config.js index e75357dff..7c6239e49 100644 --- a/plugins/dbgate-plugin-clickhouse/webpack-backend.config.js +++ b/plugins/dbgate-plugin-clickhouse/webpack-backend.config.js @@ -18,6 +18,13 @@ var config = { // optimization: { // 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; diff --git a/plugins/dbgate-plugin-csv/package.json b/plugins/dbgate-plugin-csv/package.json index 72bc027a3..41ec1803a 100644 --- a/plugins/dbgate-plugin-csv/package.json +++ b/plugins/dbgate-plugin-csv/package.json @@ -15,7 +15,7 @@ "import", "export", "dbgate", - "dbgateplugin" + "dbgatebuiltin" ], "files": [ "dist", @@ -32,11 +32,13 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "csv": "^6.3.10", "dbgate-plugin-tools": "^1.0.7", - "line-reader": "^0.4.0", - "lodash": "^4.17.21", "webpack": "^5.91.0", "webpack-cli": "^5.1.4" + }, + "dependencies": { + "csv": "^6.3.10", + "line-reader": "^0.4.0", + "lodash": "^4.17.21" } -} +} \ No newline at end of file diff --git a/plugins/dbgate-plugin-csv/src/backend/reader.js b/plugins/dbgate-plugin-csv/src/backend/reader.js index 53d0ad335..55ef181d9 100644 --- a/plugins/dbgate-plugin-csv/src/backend/reader.js +++ b/plugins/dbgate-plugin-csv/src/backend/reader.js @@ -1,4 +1,4 @@ -const zipObject = require('lodash/zipObject'); +const _ = require('lodash'); const csv = require('csv'); const fs = require('fs'); const stream = require('stream'); @@ -37,7 +37,7 @@ class CsvPrepareStream extends stream.Transform { _transform(chunk, encoding, done) { if (this.structure) { this.push( - zipObject( + _.zipObject( this.structure.columns.map((x) => x.columnName), chunk ) @@ -57,7 +57,7 @@ class CsvPrepareStream extends stream.Transform { }; this.push(this.structure); this.push( - zipObject( + _.zipObject( this.structure.columns.map((x) => x.columnName), chunk ) diff --git a/plugins/dbgate-plugin-csv/webpack-backend.config.js b/plugins/dbgate-plugin-csv/webpack-backend.config.js index e75357dff..0aec009ad 100644 --- a/plugins/dbgate-plugin-csv/webpack-backend.config.js +++ b/plugins/dbgate-plugin-csv/webpack-backend.config.js @@ -18,6 +18,12 @@ var config = { // optimization: { // minimize: false, // }, + + externals: { + csv: 'commonjs csv', + 'line-reader': 'commonjs line-reader', + lodash: 'commonjs lodash', + }, }; module.exports = config; diff --git a/plugins/dbgate-plugin-excel/package.json b/plugins/dbgate-plugin-excel/package.json index 8b8344046..2838cd794 100644 --- a/plugins/dbgate-plugin-excel/package.json +++ b/plugins/dbgate-plugin-excel/package.json @@ -15,7 +15,7 @@ "import", "export", "dbgate", - "dbgateplugin" + "dbgatebuiltin" ], "files": [ "dist", @@ -32,10 +32,12 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "lodash": "^4.17.21", - "xlsx": "0.16.9", "dbgate-plugin-tools": "^1.0.7", "webpack": "^5.91.0", "webpack-cli": "^5.1.4" + }, + "dependecies": { + "lodash": "^4.17.21", + "xlsx": "0.16.9" } } \ No newline at end of file diff --git a/plugins/dbgate-plugin-excel/webpack-backend.config.js b/plugins/dbgate-plugin-excel/webpack-backend.config.js index e75357dff..f736b4224 100644 --- a/plugins/dbgate-plugin-excel/webpack-backend.config.js +++ b/plugins/dbgate-plugin-excel/webpack-backend.config.js @@ -18,6 +18,11 @@ var config = { // optimization: { // minimize: false, // }, + + externals: { + xlsx: 'commonjs xlsx', + lodash: 'commonjs lodash', + }, }; module.exports = config; diff --git a/plugins/dbgate-plugin-mongo/package.json b/plugins/dbgate-plugin-mongo/package.json index f12580424..0f90ed430 100644 --- a/plugins/dbgate-plugin-mongo/package.json +++ b/plugins/dbgate-plugin-mongo/package.json @@ -12,9 +12,9 @@ }, "keywords": [ "dbgate", - "dbgateplugin", "mongo", - "mongodb" + "mongodb", + "dbgatebuiltin" ], "files": [ "dist", @@ -31,15 +31,19 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "bson": "^6.8.0", "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-tools": "^5.0.0-alpha.1", "is-promise": "^4.0.0", "lodash": "^4.17.21", - "mongodb": "^6.3.0", - "mongodb-client-encryption": "^6.0.0", - "webpack": "^5.91.0", - "webpack-cli": "^5.1.4" + "mongodb": "^6.3.0" + }, + "optionalDependencies": { + "mongodb-client-encryption": "^6.0.0" } } diff --git a/plugins/dbgate-plugin-mongo/webpack-backend.config.js b/plugins/dbgate-plugin-mongo/webpack-backend.config.js index e75357dff..c6cfde2f4 100644 --- a/plugins/dbgate-plugin-mongo/webpack-backend.config.js +++ b/plugins/dbgate-plugin-mongo/webpack-backend.config.js @@ -18,6 +18,16 @@ var config = { // optimization: { // 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; diff --git a/plugins/dbgate-plugin-mssql/package.json b/plugins/dbgate-plugin-mssql/package.json index ea4d980b8..ee4178a56 100644 --- a/plugins/dbgate-plugin-mssql/package.json +++ b/plugins/dbgate-plugin-mssql/package.json @@ -14,7 +14,7 @@ "sql", "mssql", "dbgate", - "dbgateplugin" + "dbgatebuiltin" ], "files": [ "dist", @@ -31,12 +31,18 @@ "plugout": "dbgate-plugout dbgate-plugin-mssql" }, "devDependencies": { - "async-lock": "^1.2.6", "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-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" } } diff --git a/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js b/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js index 1d47dd6f4..1eac0ea32 100644 --- a/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js +++ b/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js @@ -1,4 +1,3 @@ -const fp = require('lodash/fp'); const _ = require('lodash'); const sql = require('./sql'); diff --git a/plugins/dbgate-plugin-mssql/src/backend/driver.js b/plugins/dbgate-plugin-mssql/src/backend/driver.js index 260613d73..5cd719b92 100644 --- a/plugins/dbgate-plugin-mssql/src/backend/driver.js +++ b/plugins/dbgate-plugin-mssql/src/backend/driver.js @@ -5,15 +5,13 @@ const MsSqlAnalyser = require('./MsSqlAnalyser'); const createTediousBulkInsertStream = require('./createTediousBulkInsertStream'); const createNativeBulkInsertStream = require('./createNativeBulkInsertStream'); const AsyncLock = require('async-lock'); -const nativeDriver = require('./nativeDriver'); const lock = new AsyncLock(); 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 logger = getLogger('mssqlDriver'); -let requireMsnodesqlv8; let platformInfo; let authProxy; @@ -59,7 +57,7 @@ const driver = { getAuthTypes() { const res = []; - if (requireMsnodesqlv8) res.push(...windowsAuthTypes); + if (platformInfo?.isWindows) res.push(...windowsAuthTypes); if (authProxy.isAuthProxySupported()) { res.push( @@ -82,7 +80,7 @@ const driver = { async connect(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); return { @@ -172,12 +170,8 @@ const driver = { }; driver.initialize = dbgateEnv => { - if (dbgateEnv.nativeModules && dbgateEnv.nativeModules.msnodesqlv8) { - requireMsnodesqlv8 = dbgateEnv.nativeModules.msnodesqlv8; - } platformInfo = dbgateEnv.platformInfo; authProxy = dbgateEnv.authProxy; - nativeDriver.initialize(dbgateEnv); }; module.exports = driver; diff --git a/plugins/dbgate-plugin-mssql/src/backend/nativeDriver.js b/plugins/dbgate-plugin-mssql/src/backend/nativeDriver.js index 6ba14f634..5c15bda87 100644 --- a/plugins/dbgate-plugin-mssql/src/backend/nativeDriver.js +++ b/plugins/dbgate-plugin-mssql/src/backend/nativeDriver.js @@ -1,7 +1,6 @@ const _ = require('lodash'); const stream = require('stream'); const makeUniqueColumnNames = require('./makeUniqueColumnNames'); -let requireMsnodesqlv8; const { extractDbNameFromComposite } = global.DBGATE_PACKAGES['dbgate-tools']; // async function nativeQueryCore(pool, sql, options) { @@ -24,7 +23,7 @@ const { extractDbNameFromComposite } = global.DBGATE_PACKAGES['dbgate-tools']; let msnodesqlv8Value; function getMsnodesqlv8() { if (!msnodesqlv8Value) { - msnodesqlv8Value = requireMsnodesqlv8(); + msnodesqlv8Value = require('msnodesqlv8'); } 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 = { nativeConnect, nativeQueryCore, nativeReadQuery, nativeStream, - initialize, }; diff --git a/plugins/dbgate-plugin-mssql/webpack-backend.config.js b/plugins/dbgate-plugin-mssql/webpack-backend.config.js index c00656b5f..cb2b45aa6 100644 --- a/plugins/dbgate-plugin-mssql/webpack-backend.config.js +++ b/plugins/dbgate-plugin-mssql/webpack-backend.config.js @@ -17,6 +17,15 @@ var config = { // optimization: { // 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; diff --git a/plugins/dbgate-plugin-mysql/package.json b/plugins/dbgate-plugin-mysql/package.json index 1c01475ce..bade03c3e 100644 --- a/plugins/dbgate-plugin-mysql/package.json +++ b/plugins/dbgate-plugin-mysql/package.json @@ -13,8 +13,8 @@ "keywords": [ "sql", "dbgate", - "dbgateplugin", - "mysql" + "mysql", + "dbgatebuiltin" ], "files": [ "dist", @@ -31,12 +31,15 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "antares-mysql-dumper": "^0.0.1", "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-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" } } diff --git a/plugins/dbgate-plugin-mysql/src/backend/Analyser.js b/plugins/dbgate-plugin-mysql/src/backend/Analyser.js index fb18cc683..ae68e0ce2 100644 --- a/plugins/dbgate-plugin-mysql/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-mysql/src/backend/Analyser.js @@ -1,4 +1,3 @@ -const fp = require('lodash/fp'); const _ = require('lodash'); const sql = require('./sql'); @@ -172,7 +171,7 @@ class Analyser extends DatabaseAnalyser { })), procedures: programmables.rows .filter(x => x.objectType == 'PROCEDURE') - .map(fp.omit(['objectType'])) + .map(x => _.omit(x, ['objectType'])) .map(x => ({ ...x, createSql: `DELIMITER //\n\nCREATE PROCEDURE \`${x.pureName}\`()\n${x.routineDefinition}\n\nDELIMITER ;\n`, @@ -181,7 +180,7 @@ class Analyser extends DatabaseAnalyser { })), functions: programmables.rows .filter(x => x.objectType == 'FUNCTION') - .map(fp.omit(['objectType'])) + .map(x => _.omit(x, ['objectType'])) .map(x => ({ ...x, createSql: `CREATE FUNCTION \`${x.pureName}\`()\nRETURNS ${x.returnDataType} ${ diff --git a/plugins/dbgate-plugin-mysql/webpack-backend.config.js b/plugins/dbgate-plugin-mysql/webpack-backend.config.js index 87b665d56..21556f075 100644 --- a/plugins/dbgate-plugin-mysql/webpack-backend.config.js +++ b/plugins/dbgate-plugin-mysql/webpack-backend.config.js @@ -14,6 +14,14 @@ var config = { 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 // optimization: { // minimize: false, diff --git a/plugins/dbgate-plugin-oracle/package.json b/plugins/dbgate-plugin-oracle/package.json index 8db9248f5..e9773fc96 100644 --- a/plugins/dbgate-plugin-oracle/package.json +++ b/plugins/dbgate-plugin-oracle/package.json @@ -12,8 +12,8 @@ "author": "Rinie Kervel", "keywords": [ "dbgate", - "dbgateplugin", - "oracle" + "oracle", + "dbgatebuiltin" ], "files": [ "dist", @@ -31,10 +31,15 @@ }, "devDependencies": { "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-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" } } diff --git a/plugins/dbgate-plugin-oracle/src/backend/Analyser.js b/plugins/dbgate-plugin-oracle/src/backend/Analyser.js index 5b4b845c8..bbb851f28 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-oracle/src/backend/Analyser.js @@ -1,4 +1,3 @@ -const fp = require('lodash/fp'); const _ = require('lodash'); const sql = require('./sql'); diff --git a/plugins/dbgate-plugin-oracle/src/backend/driver.js b/plugins/dbgate-plugin-oracle/src/backend/driver.js index 8a44b77ef..c85840fb3 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/driver.js +++ b/plugins/dbgate-plugin-oracle/src/backend/driver.js @@ -6,13 +6,12 @@ const Analyser = require('./Analyser'); const { createBulkInsertStreamBase, makeUniqueColumnNames } = global.DBGATE_PACKAGES['dbgate-tools']; const createOracleBulkInsertStream = require('./createOracleBulkInsertStream'); -let requireOracledb; let platformInfo; let oracledbValue; function getOracledb() { if (!oracledbValue) { - oracledbValue = requireOracledb(); + oracledbValue = require('oracledb'); } return oracledbValue; } @@ -359,9 +358,6 @@ const driver = { }; driver.initialize = dbgateEnv => { - if (dbgateEnv.nativeModules && dbgateEnv.nativeModules['oracledb']) { - requireOracledb = dbgateEnv.nativeModules['oracledb']; - } platformInfo = dbgateEnv.platformInfo; }; diff --git a/plugins/dbgate-plugin-oracle/webpack-backend.config.js b/plugins/dbgate-plugin-oracle/webpack-backend.config.js index 05b19540e..b93eb6f46 100644 --- a/plugins/dbgate-plugin-oracle/webpack-backend.config.js +++ b/plugins/dbgate-plugin-oracle/webpack-backend.config.js @@ -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; diff --git a/plugins/dbgate-plugin-postgres/package.json b/plugins/dbgate-plugin-postgres/package.json index 3b80049c0..53bcbdc42 100644 --- a/plugins/dbgate-plugin-postgres/package.json +++ b/plugins/dbgate-plugin-postgres/package.json @@ -12,8 +12,8 @@ "author": "Jan Prochazka", "keywords": [ "dbgate", - "dbgateplugin", - "postgresql" + "postgresql", + "dbgatebuiltin" ], "files": [ "dist", @@ -31,14 +31,14 @@ }, "devDependencies": { "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-cli": "^5.1.4" }, "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" } } diff --git a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js index 8fba8d643..84b67a858 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js @@ -1,4 +1,3 @@ -const fp = require('lodash/fp'); const _ = require('lodash'); const sql = require('./sql'); diff --git a/plugins/dbgate-plugin-postgres/webpack-backend.config.js b/plugins/dbgate-plugin-postgres/webpack-backend.config.js index fb19d92d1..015fda186 100644 --- a/plugins/dbgate-plugin-postgres/webpack-backend.config.js +++ b/plugins/dbgate-plugin-postgres/webpack-backend.config.js @@ -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; diff --git a/plugins/dbgate-plugin-redis/package.json b/plugins/dbgate-plugin-redis/package.json index d49c3d575..e4a4832c6 100644 --- a/plugins/dbgate-plugin-redis/package.json +++ b/plugins/dbgate-plugin-redis/package.json @@ -12,8 +12,8 @@ "author": "Jan Prochazka", "keywords": [ "dbgate", - "dbgateplugin", - "redis" + "redis", + "dbgatebuiltin" ], "files": [ "dist" @@ -30,11 +30,13 @@ }, "devDependencies": { "dbgate-plugin-tools": "^1.0.7", + "webpack": "^5.91.0", + "webpack-cli": "^5.1.4" + }, + "dependencies": { "dbgate-query-splitter": "^4.11.2", "dbgate-tools": "^5.0.0-alpha.1", "lodash": "^4.17.21", - "webpack": "^5.91.0", - "webpack-cli": "^5.1.4", "async": "^3.2.3", "ioredis": "^5.4.1", "node-redis-dump2": "^0.5.0" diff --git a/plugins/dbgate-plugin-redis/webpack-backend.config.js b/plugins/dbgate-plugin-redis/webpack-backend.config.js index e75357dff..325d4ff74 100644 --- a/plugins/dbgate-plugin-redis/webpack-backend.config.js +++ b/plugins/dbgate-plugin-redis/webpack-backend.config.js @@ -18,6 +18,14 @@ var config = { // optimization: { // 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; diff --git a/plugins/dbgate-plugin-sqlite/package.json b/plugins/dbgate-plugin-sqlite/package.json index 850d62a6a..933968aa7 100644 --- a/plugins/dbgate-plugin-sqlite/package.json +++ b/plugins/dbgate-plugin-sqlite/package.json @@ -1,41 +1,45 @@ { - "name": "dbgate-plugin-sqlite", - "main": "dist/backend.js", - "version": "5.0.0-alpha.1", - "homepage": "https://dbgate.org", - "description": "SQLite connect plugin for DbGate", - "repository": { - "type": "git", - "url": "https://github.com/dbgate/dbgate" - }, - "author": "Jan Prochazka", - "license": "GPL-3.0", - "keywords": [ - "dbgate", - "dbgateplugin", - "sqlite" - ], - "files": [ - "dist", - "icon.svg" - ], - "scripts": { - "build:frontend": "webpack --config webpack-frontend.config", - "build:frontend:watch": "webpack --watch --config webpack-frontend.config", - "build:backend": "webpack --config webpack-backend.config.js", - "build": "yarn build:frontend && yarn build:backend", - "plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-sqlite", - "copydist": "yarn build && yarn pack && dbgate-copydist ../dist/dbgate-plugin-sqlite", - "plugout": "dbgate-plugout dbgate-plugin-sqlite", - "prepublishOnly": "yarn build" - }, - "devDependencies": { - "dbgate-tools": "^5.0.0-alpha.1", - "dbgate-plugin-tools": "^1.0.4", - "dbgate-query-splitter": "^4.11.2", - "byline": "^5.0.0", - "webpack": "^5.91.0", - "webpack-cli": "^5.1.4" - } + "name": "dbgate-plugin-sqlite", + "main": "dist/backend.js", + "version": "5.0.0-alpha.1", + "homepage": "https://dbgate.org", + "description": "SQLite connect plugin for DbGate", + "repository": { + "type": "git", + "url": "https://github.com/dbgate/dbgate" + }, + "author": "Jan Prochazka", + "license": "GPL-3.0", + "keywords": [ + "dbgate", + "sqlite", + "dbgatebuiltin" + ], + "files": [ + "dist", + "icon.svg" + ], + "scripts": { + "build:frontend": "webpack --config webpack-frontend.config", + "build:frontend:watch": "webpack --watch --config webpack-frontend.config", + "build:backend": "webpack --config webpack-backend.config.js", + "build": "yarn build:frontend && yarn build:backend", + "plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-sqlite", + "copydist": "yarn build && yarn pack && dbgate-copydist ../dist/dbgate-plugin-sqlite", + "plugout": "dbgate-plugout dbgate-plugin-sqlite", + "prepublishOnly": "yarn build" + }, + "devDependencies": { + "dbgate-plugin-tools": "^1.0.4", + "webpack": "^5.91.0", + "webpack-cli": "^5.1.4" + }, + "dependencies": { + "dbgate-tools": "^5.0.0-alpha.1", + "lodash": "^4.17.21", + "dbgate-query-splitter": "^4.11.2" + }, + "optionalDependencies": { + "better-sqlite3": "9.6.0" } - \ No newline at end of file +} diff --git a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js index e61bea08e..8e054fd56 100644 --- a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js @@ -1,5 +1,5 @@ const _ = require('lodash'); -const { DatabaseAnalyser } = global.DBGATE_PACKAGES['dbgate-tools'];; +const { DatabaseAnalyser } = global.DBGATE_PACKAGES['dbgate-tools']; const indexcolsQuery = ` SELECT diff --git a/plugins/dbgate-plugin-sqlite/src/backend/driver.js b/plugins/dbgate-plugin-sqlite/src/backend/driver.js index 1e624aea1..5650da1bf 100644 --- a/plugins/dbgate-plugin-sqlite/src/backend/driver.js +++ b/plugins/dbgate-plugin-sqlite/src/backend/driver.js @@ -7,12 +7,10 @@ const { getLogger, createBulkInsertStreamBase, extractErrorLogData } = global.DB const logger = getLogger('sqliteDriver'); -let requireBetterSqlite; - let betterSqliteValue; function getBetterSqlite() { if (!betterSqliteValue) { - betterSqliteValue = requireBetterSqlite(); + betterSqliteValue = require('better-sqlite3'); } return betterSqliteValue; } @@ -188,10 +186,6 @@ const driver = { }, }; -driver.initialize = (dbgateEnv) => { - if (dbgateEnv.nativeModules && dbgateEnv.nativeModules['better-sqlite3']) { - requireBetterSqlite = dbgateEnv.nativeModules['better-sqlite3']; - } -}; +driver.initialize = (dbgateEnv) => {}; module.exports = driver; diff --git a/plugins/dbgate-plugin-sqlite/webpack-backend.config.js b/plugins/dbgate-plugin-sqlite/webpack-backend.config.js index e75357dff..7e76c3c96 100644 --- a/plugins/dbgate-plugin-sqlite/webpack-backend.config.js +++ b/plugins/dbgate-plugin-sqlite/webpack-backend.config.js @@ -18,6 +18,12 @@ var config = { // optimization: { // 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; diff --git a/plugins/dbgate-plugin-xml/package.json b/plugins/dbgate-plugin-xml/package.json index b119ef4e0..29237cf8b 100644 --- a/plugins/dbgate-plugin-xml/package.json +++ b/plugins/dbgate-plugin-xml/package.json @@ -15,7 +15,7 @@ "import", "export", "dbgate", - "dbgateplugin" + "dbgatebuiltin" ], "files": [ "dist" @@ -31,9 +31,11 @@ "prepublishOnly": "yarn build" }, "devDependencies": { - "node-xml-stream-parser": "^1.0.12", "dbgate-plugin-tools": "^1.0.7", "webpack": "^5.91.0", "webpack-cli": "^5.1.4" + }, + "dependencies": { + "node-xml-stream-parser": "^1.0.12" } } diff --git a/plugins/dbgate-plugin-xml/webpack-backend.config.js b/plugins/dbgate-plugin-xml/webpack-backend.config.js index e75357dff..c5be54c72 100644 --- a/plugins/dbgate-plugin-xml/webpack-backend.config.js +++ b/plugins/dbgate-plugin-xml/webpack-backend.config.js @@ -18,6 +18,9 @@ var config = { // optimization: { // minimize: false, // }, + externals: { + 'node-xml-stream-parser': 'commonjs node-xml-stream-parser', + }, }; module.exports = config; diff --git a/setCurrentVersion.js b/setCurrentVersion.js index 4597397e2..d448ac61a 100644 --- a/setCurrentVersion.js +++ b/setCurrentVersion.js @@ -39,19 +39,12 @@ changePackageFile('packages/types', json.version); changePackageFile('packages/tools', json.version); changePackageFile('packages/web', json.version); changePackageFile('packages/datalib', json.version); -changePackageFile('packages/dbgate', json.version); changePackageFile('packages/serve', json.version); changePackageFile('packages/filterparser', json.version); changePackageFile('packages/dbmodel', json.version); -changePackageFile('plugins/dbgate-plugin-csv', json.version); -changePackageFile('plugins/dbgate-plugin-xml', json.version); -changePackageFile('plugins/dbgate-plugin-excel', json.version); -changePackageFile('plugins/dbgate-plugin-mssql', 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); +for (const package of fs.readdirSync('plugins')) { + if (!package.startsWith('dbgate-plugin-')) continue; + + changePackageFile(`plugins/${package}`, json.version); +}