Skip to content

Commit

Permalink
Update code for building with TS 2.8
Browse files Browse the repository at this point in the history
* Update to @theintern/dev 0.7 with TS 2.8
* Support strictPropertyInitialization flag
* Some general cleanup
  • Loading branch information
jason0x43 committed Apr 19, 2018
1 parent bf89496 commit c6b1022
Show file tree
Hide file tree
Showing 11 changed files with 6,297 additions and 4,097 deletions.
8,386 changes: 4,757 additions & 3,629 deletions docs/api.json

Large diffs are not rendered by default.

1,676 changes: 1,353 additions & 323 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@dojo/loader": "~0.1.1",
"@theintern/dev": "~0.6.6",
"@theintern/dev": "~0.7.0",
"@types/node": "~9.6.5",
"@types/semver": "~5.5.0",
"@types/shelljs": "~0.7.1",
Expand Down
14 changes: 8 additions & 6 deletions src/BrowserStackTunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ export default class BrowserStackTunnel extends Tunnel {
* Whether or not to start the tunnel with only WebDriver support. Setting
* this value to `false` is not supported.
*/
automateOnly: boolean;
automateOnly: true | undefined;

/**
* If true, any other tunnels running on the account will be killed when
* the tunnel is started.
*/
killOtherTunnels: boolean;
killOtherTunnels: boolean | undefined;

/**
* A list of server URLs that should be proxied by the tunnel. Only the
* hostname, port, and protocol are used.
*/
servers: (Url | string)[];
servers!: (Url | string)[];

/**
* Skip verification that the proxied servers are online and responding at
* the time the tunnel starts.
*/
skipServerValidation: boolean;
skipServerValidation: boolean | undefined;

/** If true, route all traffic via the local machine. */
forceLocal: boolean;
forceLocal: boolean | undefined;

constructor(options?: BrowserStackOptions) {
super(
Expand Down Expand Up @@ -201,7 +201,9 @@ export default class BrowserStackTunnel extends Tunnel {
return response.text().then(text => {
throw new Error(
text ||
`Server reported ${response.status} with no other data.`
`Server reported ${
response.status
} with no other data.`
);
});
}
Expand Down
52 changes: 29 additions & 23 deletions src/CrossBrowserTestingTunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Task from '@dojo/core/async/Task';
import { createCompositeHandle, mixin } from '@dojo/core/lang';
import { exec } from 'child_process';

const cbtVersion = '0.1.0';
const cbtVersion = '0.9.3';

/**
* A CrossBrowserTesting tunnel.
Expand Down Expand Up @@ -47,7 +47,25 @@ const cbtVersion = '0.1.0';
* and CBT_APIKEY.
*/
export default class CrossBrowserTestingTunnel extends Tunnel {
cbtVersion: string;
cbtVersion!: string;

constructor(options?: TunnelProperties) {
super(
mixin(
{
accessKey: process.env.CBT_APIKEY,
cbtVersion,
environmentUrl:
'https://crossbrowsertesting.com/api/v3/selenium/browsers?format=json',
executable: 'node',
hostname: 'hub.crossbrowsertesting.com',
port: '80',
username: process.env.CBT_USERNAME
},
options || {}
)
);
}

get auth() {
return `${this.username || ''}:${this.accessKey || ''}`;
Expand All @@ -69,24 +87,6 @@ export default class CrossBrowserTestingTunnel extends Tunnel {
}
}

constructor(options?: TunnelProperties) {
super(
mixin(
{
accessKey: process.env.CBT_APIKEY,
cbtVersion,
environmentUrl:
'https://crossbrowsertesting.com/api/v3/selenium/browsers?format=json',
executable: 'node',
hostname: 'hub.crossbrowsertesting.com',
port: '80',
username: process.env.CBT_USERNAME
},
options || {}
)
);
}

download(forceDownload = false): Task<void> {
if (!forceDownload && this.isDownloaded) {
return Task.resolve();
Expand Down Expand Up @@ -152,16 +152,22 @@ export default class CrossBrowserTestingTunnel extends Tunnel {

if (data.status) {
throw new Error(
`Could not save test status (${data.message})`
`Could not save test status (${
data.message
})`
);
}

throw new Error(
`Server reported ${response.status} with: ${text}`
`Server reported ${
response.status
} with: ${text}`
);
} else {
throw new Error(
`Server reported ${response.status} with no other data.`
`Server reported ${
response.status
} with no other data.`
);
}
});
Expand Down
66 changes: 39 additions & 27 deletions src/SauceLabsTunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { mixin } from '@dojo/core/lang';
import { fileExists, on } from './util';
import * as kill from 'tree-kill';

const scVersion = '4.4.7';
const scVersion = '4.4.12';

/**
* A Sauce Labs tunnel. This tunnel uses Sauce Connect 4 on platforms where it
Expand All @@ -27,92 +27,99 @@ const scVersion = '4.4.7';
*/
export default class SauceLabsTunnel extends Tunnel
implements SauceLabsProperties {
accessKey!: string;

/**
* A list of domains that should not be proxied by the tunnel on the remote
* VM.
*/
directDomains: string[];
directDomains!: string[];

/**
* A list of domains that will be proxied by the tunnel on the remote VM.
*/
tunnelDomains: string[];
tunnelDomains!: string[];

/**
* A list of URLs that require additional HTTP authentication. Only the
* hostname, port, and auth are used. This property is only supported by
* Sauce Connect 4 tunnels.
*/
domainAuthentication: string[];
domainAuthentication!: string[];

/**
* A list of regular expressions corresponding to domains whose connections
* should fail immediately if the VM attempts to make a connection to them.
*/
fastFailDomains: string[];
fastFailDomains!: string[];

/**
* Allows the tunnel to also be used by sub-accounts of the user that
* started the tunnel.
*/
isSharedTunnel: boolean;
isSharedTunnel!: boolean;

/** A filename where additional logs from the tunnel should be output. */
logFile: string;
logFile: string | undefined;

/**
* The absolute filepath (or URL) of a file which Sauce Connect should use
* for additional proxy configuration. Sauce Connect suggests using either
* this or `proxy`, but not both.
*/
pacFile: string;
pacFile: string | undefined;

/** A filename where Sauce Connect stores its process information. */
pidFile: string;
pidFile: string | undefined;

/**
* Specifies the maximum log filesize before rotation, in bytes. This
* property is only supported by Sauce Connect 3 tunnels.
*/
logFileSize: number;
logFileSize: number | undefined;

/**
* Log statistics about HTTP traffic every `logTrafficStats` milliseconds.
* This property is only supported by Sauce Connect 4 tunnels.
*/
logTrafficStats: number;
logTrafficStats!: number;

/**
* An alternative URL for the Sauce REST API. This property is only
* supported by Sauce Connect 3 tunnels.
*/
restUrl: string;
restUrl: string | undefined;

/**
* A list of domains that should not have their SSL connections re-encrypted
* when going through the tunnel.
*/
skipSslDomains: string[];
skipSslDomains!: string[];

/**
* An additional set of options to use with the Squid proxy for the remote
* VM. This property is only supported by Sauce Connect 3 tunnels.
*/
squidOptions: string;
squidOptions: string | undefined;

/**
* Whether or not to use the proxy defined at [[Tunnel.proxy]] for the
* tunnel connection itself.
*/
useProxyForTunnel: boolean;
useProxyForTunnel!: boolean;

/**
* Overrides the version of the VM created on Sauce Labs. This property is
* only supported by Sauce Connect 3 tunnels.
*/
vmVersion: string;
vmVersion: string | undefined;

/**
* The version of Sauce Connect that should be used
*/
scVersion!: string;

scVersion: string;
username!: string;

constructor(options?: SauceLabsOptions) {
super(
Expand Down Expand Up @@ -355,12 +362,16 @@ export default class SauceLabsTunnel extends Tunnel

if (response.status !== 200) {
throw new Error(
`Server reported ${response.status} with: ${text}`
`Server reported ${
response.status
} with: ${text}`
);
}
} else {
throw new Error(
`Server reported ${response.status} with no other data.`
`Server reported ${
response.status
} with no other data.`
);
}
});
Expand Down Expand Up @@ -485,9 +496,10 @@ export default class SauceLabsTunnel extends Tunnel
if (!readMessage) {
return;
}

String(data)
.split('\n')
.some(function(message) {
.some(message => {
// Get rid of the date/time prefix on each message
const delimiter = message.indexOf(' - ');
if (delimiter > -1) {
Expand Down Expand Up @@ -595,16 +607,16 @@ export interface SauceLabsProperties extends TunnelProperties {
domainAuthentication: string[];
fastFailDomains: string[];
isSharedTunnel: boolean;
logFile: string;
pacFile: string;
pidFile: string;
logFileSize: number;
logFile: string | undefined;
pacFile: string | undefined;
pidFile: string | undefined;
logFileSize: number | undefined;
logTrafficStats: number;
restUrl: string;
restUrl: string | undefined;
skipSslDomains: string[];
squidOptions: string;
squidOptions: string | undefined;
useProxyForTunnel: boolean;
vmVersion: string;
vmVersion: string | undefined;
}

export type SauceLabsOptions = Partial<SauceLabsProperties>;
Loading

0 comments on commit c6b1022

Please sign in to comment.