Skip to content

Commit

Permalink
Self-host deelay proxy (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador authored Dec 13, 2022
1 parent d827d42 commit e4f678d
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 10 deletions.
3 changes: 2 additions & 1 deletion examples/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"storybook": "(adb reverse tcp:7007 tcp:7007 > /dev/null || true) && echo 'y' | start-storybook -p 7007 | react-native start --projectRoot storybook --watchFolders $PWD",
"storybook": "(adb reverse tcp:7007 tcp:7007 > /dev/null || true) && echo 'y' | start-storybook -p 7007 | react-native start --projectRoot storybook --watchFolders $PWD | deelay",
"update-loki": "LOKI_FILE=`cd ../.. && echo \\`pwd\\`/\\`npm pack\\`` && npm install $LOKI_FILE --no-save && rm $LOKI_FILE"
},
"dependencies": {
Expand All @@ -24,6 +24,7 @@
"@storybook/react-native": "^5.3.23",
"@storybook/react-native-server": "^5.3.23",
"babel-jest": "^26.6.3",
"deelay": "^2.0.0",
"jest": "^26.6.3",
"loki": "*",
"metro-react-native-babel-preset": "^0.67.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-native/storybook/stories/Logo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Image } from 'react-native';

const DELAY_URL_PREFIX = 'https://www.deelay.me';
const DELAY_URL_PREFIX = 'http://localhost:4567';

const Logo = ({ delay, logoUrl }) => (
<Image
Expand Down
6 changes: 4 additions & 2 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"build": "react-scripts build",
"test": "loki",
"pretest-ci": "build-storybook",
"test-ci": "loki --requireReference --reactUri file:./storybook-static",
"test-ci": "concurrently --kill-others --raw --success first 'loki --requireReference --reactUri file:./storybook-static' 'deelay'",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"storybook": "concurrently --kill-others --raw --success first 'start-storybook -p 6006 -s public' 'deelay'",
"build-storybook": "build-storybook -s public --quiet"
},
"eslintConfig": {
Expand Down Expand Up @@ -52,6 +52,8 @@
"@storybook/preset-create-react-app": "^4.1.0",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"concurrently": "^7.6.0",
"deelay": "^2.0.0",
"loki": "^0.30.3",
"webpack": "^5.70.0"
}
Expand Down
7 changes: 5 additions & 2 deletions examples/react/src/async/Logo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';

const DELAY_URL_PREFIX = 'http://www.deelay.me';
const getDelayUrl = (url, delay) =>
`http://${
window.navigator.webdriver ? 'host.docker.internal' : 'localhost'
}:4567/${delay}/${url}`;

const Logo = ({ delay, logoUrl }) => (
<img
style={{ width: 75, height: 75 }}
alt=""
src={delay ? `${DELAY_URL_PREFIX}/${delay}/${logoUrl}` : logoUrl}
src={delay ? getDelayUrl(logoUrl, delay) : logoUrl}
/>
);

Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/commands/approve/parse-options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const minimist = require('minimist');
const defaults = require('../test/default-options');
const defaults = require('../test/default-options.json');

function parseOptions(args, config) {
const argv = minimist(args);
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/commands/test/parse-options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const minimist = require('minimist');
const ciInfo = require('ci-info');
const defaults = require('./default-options');
const defaults = require('./default-options.json');

function parseOptions(args, config) {
const argv = minimist(args, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function createChromeDockerTarget({
if (!chromeDockerWithoutSeccomp) {
runArgs.push(`--security-opt=seccomp=${__dirname}/docker-seccomp.json`);
}
runArgs.push('--add-host=host.docker.internal:host-gateway');

if (dockerUrl.indexOf('http://localhost') === 0) {
const ip = getLocalIPAddress();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs-extra');
const tempy = require('tempy');
const osnap = require('@ferocia-oss/src/android');
const osnap = require('@ferocia-oss/osnap/src/android');
const { createWebsocketTarget } = require('@loki/target-native-core');

const captureScreenshot = async (device) => {
Expand Down
76 changes: 75 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7571,6 +7571,15 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"

cliui@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.1"
wrap-ansi "^7.0.0"

clone-deep@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
Expand Down Expand Up @@ -7868,6 +7877,21 @@ concat-with-sourcemaps@*:
dependencies:
source-map "^0.6.1"

concurrently@^7.6.0:
version "7.6.0"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.6.0.tgz#531a6f5f30cf616f355a4afb8f8fcb2bba65a49a"
integrity sha512-BKtRgvcJGeZ4XttiDiNcFiRlxoAeZOseqUvyYRUp/Vtd+9p1ULmeoSqGsDA+2ivdeDFpqrJvGvmI+StKfKl5hw==
dependencies:
chalk "^4.1.0"
date-fns "^2.29.1"
lodash "^4.17.21"
rxjs "^7.0.0"
shell-quote "^1.7.3"
spawn-command "^0.0.2-1"
supports-color "^8.1.0"
tree-kill "^1.2.2"
yargs "^17.3.1"

config-chain@^1.1.11:
version "1.1.12"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa"
Expand Down Expand Up @@ -8674,6 +8698,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

date-fns@^2.29.1:
version "2.29.3"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==

dateformat@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
Expand Down Expand Up @@ -8821,6 +8850,11 @@ dedent@^0.7.0:
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=

deelay@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/deelay/-/deelay-2.0.0.tgz#8804351b51c1d5dcbb60473a4df9eafab4e172ba"
integrity sha512-fT9u5WAwtuYM2oZjrwvkWW7DYYZ+AGIbakUx3w/FR2BjwyxXaK7XoxubQ2+MpFEa+qzVWldsO3ek5oxPexT4UA==

deep-equal@^1.0.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
Expand Down Expand Up @@ -18684,6 +18718,13 @@ rxjs@^6.4.0, rxjs@^6.6.3:
dependencies:
tslib "^1.9.0"

rxjs@^7.0.0:
version "7.6.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.6.0.tgz#361da5362b6ddaa691a2de0b4f2d32028f1eb5a2"
integrity sha512-DDa7d8TFNUalGC9VqXvQ1euWNN7sc63TrUCuM9J998+ViviahMIjKSOU7rfcgFOF+FCD71BhDRv4hrFz+ImDLQ==
dependencies:
tslib "^2.1.0"

[email protected]:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
Expand Down Expand Up @@ -19344,6 +19385,11 @@ space-separated-tokens@^1.0.0:
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.4.tgz#27910835ae00d0adfcdbd0ad7e611fb9544351fa"
integrity sha512-UyhMSmeIqZrQn2UdjYpxEkwY9JUrn8pP+7L4f91zRzOQuI8MF1FGLfYU9DKCYeLdo7LXMxwrX5zKFy7eeeVHuA==

spawn-command@^0.0.2-1:
version "0.0.2-1"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
integrity sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==

spdx-correct@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9"
Expand Down Expand Up @@ -19918,7 +19964,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

supports-color@^8.0.0:
supports-color@^8.0.0, supports-color@^8.1.0:
version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
Expand Down Expand Up @@ -20475,6 +20521,11 @@ transliteration@^2.2.0:
dependencies:
yargs "^16.1.0"

tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==

tree-node-cli@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/tree-node-cli/-/tree-node-cli-1.2.5.tgz#afd75437976bbf2cc0c52b9949798e7530e8fd8c"
Expand Down Expand Up @@ -20587,6 +20638,11 @@ tslib@^2.0.3, tslib@^2.3.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==

tslib@^2.1.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==

tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
Expand Down Expand Up @@ -22015,6 +22071,11 @@ yargs-parser@^20.2.2:
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==

yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==

yargs@^14.2.2:
version "14.2.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.2.tgz#2769564379009ff8597cdd38fba09da9b493c4b5"
Expand Down Expand Up @@ -22058,6 +22119,19 @@ yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.3.1:
version "17.6.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.2.tgz#2e23f2944e976339a1ee00f18c77fedee8332541"
integrity sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==
dependencies:
cliui "^8.0.1"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.3"
y18n "^5.0.5"
yargs-parser "^21.1.1"

yargs@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-2.3.0.tgz#e900c87250ec5cd080db6009fe3dd63156f1d7fb"
Expand Down

0 comments on commit e4f678d

Please sign in to comment.