os dependend native modules

This commit is contained in:
Jan Prochazka 2021-01-17 09:11:09 +01:00
parent ccd9a0fa70
commit c06965c79f
8 changed files with 49 additions and 13 deletions

View File

@ -35,6 +35,9 @@ jobs:
- name: setCurrentVersion
run: |
yarn setCurrentVersion
- name: fillNativeModulesElectron
run: |
yarn fillNativeModulesElectron
- name: Publish
run: |
yarn run build:app

View File

@ -1,9 +1,3 @@
const msnodesqlv8 = () => require('msnodesqlv8');
const content = require('./nativeModulesContent');
const win32Modules = {
msnodesqlv8,
};
module.exports = {
...(process.platform == 'win32' ? win32Modules : {}),
};
module.exports = content;

View 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
View 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));

View File

@ -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",

View File

@ -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"
}
}

View File

@ -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');

View File

@ -0,0 +1,7 @@
// this file is generated automatically by script fillNativeModules.js, do not edit it manually
const content = {};
module.exports = content;