fix(core): update

This commit is contained in:
Philipp Kunz 2019-11-15 21:44:11 +01:00
parent 0e9c81b898
commit 2d3f59cc65
5 changed files with 78 additions and 29 deletions

26
package-lock.json generated
View File

@ -145,6 +145,17 @@
"@pushrocks/smartpromise": "^3.0.6" "@pushrocks/smartpromise": "^3.0.6"
} }
}, },
"@pushrocks/smartenv": {
"version": "4.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.8.tgz",
"integrity": "sha512-gKEL1/ogJwss2b/xjbOen5s+9geT5XUvNXuD1qUpc1t5P9w0BaXXuLw7vz1pVRxb/NWtmPLRIdVbAxL1OmmwCg==",
"requires": {
"@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^3.0.6",
"@types/node": "^12.12.7",
"is-wsl": "^2.1.1"
}
},
"@pushrocks/smartevent": { "@pushrocks/smartevent": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",
@ -244,7 +255,6 @@
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartparam/-/smartparam-1.0.4.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartparam/-/smartparam-1.0.4.tgz",
"integrity": "sha512-UAqhnTQGBaJRptTK3qTd47Yt2ZTrAWByteow4auSNZD+k0xrpY9mTPPgKh0IwsURe0cZhj7zYNpGiekhKkL4rA==", "integrity": "sha512-UAqhnTQGBaJRptTK3qTd47Yt2ZTrAWByteow4auSNZD+k0xrpY9mTPPgKh0IwsURe0cZhj7zYNpGiekhKkL4rA==",
"dev": true,
"requires": { "requires": {
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"is-promise": "^2.1.0", "is-promise": "^2.1.0",
@ -254,8 +264,7 @@
"@pushrocks/smartpromise": { "@pushrocks/smartpromise": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==", "integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
"dev": true
} }
} }
}, },
@ -268,8 +277,7 @@
"@pushrocks/smartpromise": { "@pushrocks/smartpromise": {
"version": "3.0.6", "version": "3.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==", "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
"dev": true
}, },
"@pushrocks/smartrequest": { "@pushrocks/smartrequest": {
"version": "1.1.42", "version": "1.1.42",
@ -999,8 +1007,7 @@
"is-promise": { "is-promise": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://verdaccio.lossless.one/is-promise/-/is-promise-2.1.0.tgz", "resolved": "https://verdaccio.lossless.one/is-promise/-/is-promise-2.1.0.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
"dev": true
}, },
"is-stream": { "is-stream": {
"version": "1.1.0", "version": "1.1.0",
@ -1008,6 +1015,11 @@
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true "dev": true
}, },
"is-wsl": {
"version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/is-wsl/-/is-wsl-2.1.1.tgz",
"integrity": "sha512-umZHcSrwlDHo2TGMXv0DZ8dIUGunZ2Iv68YZnrmCiBPkZ4aaOhtv7pXJKeki9k3qJ3RJr0cDyitcl5wEH3AYog=="
},
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/isarray/-/isarray-1.0.0.tgz", "resolved": "https://verdaccio.lossless.one/isarray/-/isarray-1.0.0.tgz",

View File

@ -21,6 +21,7 @@
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartenv": "^4.0.8",
"@types/puppeteer": "^1.20.2", "@types/puppeteer": "^1.20.2",
"puppeteer": "^2.0.0" "puppeteer": "^2.0.0"
}, },

View File

@ -1,25 +1,9 @@
import puppeteer from 'puppeteer'; // module exports
export interface IEnvAwareOptions { export * from './smartpuppeteer.classes.smartpuppeteer';
forceNoSandbox?: boolean;
}
export const getEnvAwareBrowserInstance = async (optionsArg: IEnvAwareOptions = {}): Promise<puppeteer.Browser> => {
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false
},
...optionsArg
}
let chromeArgs: string[] = [];
if (process.env.CI || options.forceNoSandbox) {
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
}
const headlessBrowser = await puppeteer.launch({
args: chromeArgs
});
return headlessBrowser;
};
// direct exports
import { puppeteer } from './smartpuppeteer.plugins';
export { puppeteer }; export { puppeteer };

View File

@ -0,0 +1,39 @@
import * as plugins from './smartpuppeteer.plugins';
export interface IEnvAwareOptions {
forceNoSandbox?: boolean;
}
export const getEnvAwareBrowserInstance = async (
optionsArg: IEnvAwareOptions = {}
): Promise<plugins.puppeteer.Browser> => {
const smartenv = new plugins.smartenv.Smartenv();
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false
},
...optionsArg
};
let chromeArgs: string[] = [];
if ((process.env.CI || options.forceNoSandbox) && !smartenv.isWsl) {
chromeArgs = chromeArgs.concat([
'--no-sandbox',
'--disable-setuid-sandbox'
// '--disable-dev-shm-usage'
]);
}
let headlessBrowser: plugins.puppeteer.Browser;
if (!smartenv.isWsl) {
// lets get the actual instance
headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs
});
} else {
console.log('Detected WSL. Using chromium.');
headlessBrowser = await plugins.puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});
}
return headlessBrowser;
};

View File

@ -0,0 +1,13 @@
// @pushrocks scope
import * as smartenv from '@pushrocks/smartenv';
export {
smartenv
};
// third party scope
import puppeteer from 'puppeteer';
export {
puppeteer
}