mirror of
https://github.com/dbgate/dbgate
synced 2024-11-10 05:36:29 +00:00
os dependend native modules
This commit is contained in:
parent
ccd9a0fa70
commit
c06965c79f
3
.github/workflows/build-app.yaml
vendored
3
.github/workflows/build-app.yaml
vendored
@ -35,6 +35,9 @@ jobs:
|
||||
- name: setCurrentVersion
|
||||
run: |
|
||||
yarn setCurrentVersion
|
||||
- name: fillNativeModulesElectron
|
||||
run: |
|
||||
yarn fillNativeModulesElectron
|
||||
- name: Publish
|
||||
run: |
|
||||
yarn run build:app
|
||||
|
@ -1,9 +1,3 @@
|
||||
const msnodesqlv8 = () => require('msnodesqlv8');
|
||||
const content = require('./nativeModulesContent');
|
||||
|
||||
const win32Modules = {
|
||||
msnodesqlv8,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
...(process.platform == 'win32' ? win32Modules : {}),
|
||||
};
|
||||
module.exports = content;
|
||||
|
7
app/src/nativeModulesContent.js
Normal file
7
app/src/nativeModulesContent.js
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
// this file is generated automatically by script fillNativeModules.js, do not edit it manually
|
||||
const content = {};
|
||||
|
||||
|
||||
|
||||
module.exports = content;
|
23
fillNativeModules.js
Normal file
23
fillNativeModules.js
Normal file
@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
|
||||
let fillContent = '';
|
||||
|
||||
// if (!process.argv.includes('--electron')) {
|
||||
if (process.platform == 'win32') {
|
||||
fillContent += `content.msnodesqlv8 = () => require('msnodesqlv8');`;
|
||||
}
|
||||
|
||||
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));
|
@ -25,6 +25,8 @@
|
||||
"start:app:local": "cd app && yarn start:local",
|
||||
"setCurrentVersion": "node setCurrentVersion",
|
||||
"generatePadFile": "node generatePadFile",
|
||||
"fillNativeModules": "node fillNativeModules",
|
||||
"fillNativeModulesElectron": "node fillNativeModules --eletron",
|
||||
|
||||
"copy:docker:build": "copyfiles packages/api/dist/* docker -f && copyfiles packages/web/build/* docker -u 2 && copyfiles \"packages/web/build/**/*\" docker -u 2",
|
||||
"prepare:docker": "yarn build:web:docker && yarn build:api && yarn copy:docker:build",
|
||||
@ -35,7 +37,7 @@
|
||||
"ts:api": "yarn workspace dbgate-api ts",
|
||||
"ts:web": "yarn workspace dbgate-web ts",
|
||||
"ts": "yarn ts:api && yarn ts:web",
|
||||
"postinstall": "patch-package"
|
||||
"postinstall": "patch-package && yarn fillNativeModules"
|
||||
},
|
||||
"dependencies": {
|
||||
"concurrently": "^5.1.0",
|
||||
|
@ -36,7 +36,6 @@
|
||||
"http": "^0.0.0",
|
||||
"line-reader": "^0.4.0",
|
||||
"lodash": "^4.17.15",
|
||||
"msnodesqlv8": "^2.0.10",
|
||||
"ncp": "^2.0.0",
|
||||
"nedb-promises": "^4.0.1",
|
||||
"node-cron": "^2.0.3",
|
||||
@ -59,5 +58,8 @@
|
||||
"typescript": "^3.7.4",
|
||||
"webpack": "^4.42.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"msnodesqlv8": "^2.0.10"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
const msnodesqlv8 = () => require('msnodesqlv8');
|
||||
|
||||
const argIndex = process.argv.indexOf('--native-modules');
|
||||
const redirectFile = argIndex > 0 ? process.argv[argIndex + 1] : null;
|
||||
|
||||
// @ts-ignore
|
||||
module.exports = redirectFile ? __non_webpack_require__(redirectFile) : { msnodesqlv8 };
|
||||
module.exports = redirectFile ? __non_webpack_require__(redirectFile) : require('./nativeModulesContent');
|
||||
|
7
packages/api/src/nativeModulesContent.js
Normal file
7
packages/api/src/nativeModulesContent.js
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
// this file is generated automatically by script fillNativeModules.js, do not edit it manually
|
||||
const content = {};
|
||||
|
||||
|
||||
|
||||
module.exports = content;
|
Loading…
Reference in New Issue
Block a user